No mom it's not a "messy pile of clothes on my chair" it's an L1 cache for fast random access to my frequently used clothes in O(1) time. It needs to be big to avoid expensive cache misses (looking in my closet). I NEED to be minimizing latency, this is important to me. Please.
you are viewing a single comment's thread
view the rest of the comments
[–] 27 points 7 months ago* (5 children)

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.

  • source
  • hideshow 5 child comments
  • [–] 26 points 7 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.

  • source
  • parent
  • [–] 8 points 7 months ago (1 child)

    Not if the pile has a maximum capacity. At that point it's bounded as a fixed constant.

  • source
  • parent
  • hideshow 1 child comment
  • [–] 2 points 7 months ago* (last edited 7 months ago)

    Exactly. Since n is represented by the collection of clothes, it is O(1) if you are only going through a finite subset of the clothes. If everything is in the closet, and in no particular order, you would then do O(n) because you potentially have to go through the entire collection to find one article of clothing.

    It gets even worse if your idea of organization is placing the clothes neatly yet with no real order in a closet with multiple drawers and containers inside. In this last scenario you get O(n²) because you now have to repeatedly search through n numbers of clothing containers.

  • source
  • parent
  • [–] 6 points 7 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...

  • source
  • parent
  • [–] 4 points 7 months ago

    Idk about your pile, but mine is precariously balanced on top of a chair so it's O(1) until a literal tipping point when everything falls and then it's O(k*n) where k is the time it takes me to put away a piece of clothing in the closet/laundry (or start a new pile elsewhere).

  • source
  • parent