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.
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.
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.
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…
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).
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.
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.
Not if the pile has a maximum capacity. At that point it’s bounded as a fixed constant.
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.
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…
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).