• trougnouf@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    2 months ago

    Wouldn’t a pile of clothes have O(n) complexity? They’d still have to go through them one at a time unless the clothes have a really distinct color/shape and are in a somewhat tidy pile s.t. they can be pulled from anywhere.

    • sloppy_diffuser@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      2
      ·
      2 months ago

      Items are in a hash table using color/material type/shape as the hashing method optimized for human pattern recognition providing O(1) access. The table is smaller than the number of items causing some collisions. Those items are in a randomly sorted vector. Average case is still around O(1) with an O(n) worst case.

    • ByteJunk@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      2 months ago

      A well organized drawer or cabinet should still be O(1). It takes at least 2 more steps, assuming you don’t leave them open all the time, but the number of operations doesn’t change depending on the number of clothing items you need to retrieve.

      A pile of clothes is faster, but only for a small number of items. As the number of articles pile up, they hide older items and need to be pushed side before the intended article can be found and then retrieved. This is now O(N), and less efficient than just storing things in the proper place…