Hash it. Take every shirt, and put it in a different drawer depending on the color of the shirt. Whenever you want a shirt, all you have to do is simply open the drawer with the corresponding color. That’s hashing in a nutshell.
Conceptually easy, if only because most classes hop over this with idealizations. The legendary Udi Manber was fond of saying, “hashing, hashing, hashing”. No, real hashing is hard, but don’t be afraid to use it. Imagine you have a closet full of shirts. It’s very hard to find a shirt. So what can you do?
Of course, you might (and likely) have more than one shirts of a given color. That is hash collision, and there are tons of research papers in the world on the topic, so know that they exist.
To paraphrase, no one ever got fired for using a hashtable before!
I would argue that the COLOR of the shirt is less important than the OCCASION you wear the shirt for.
The best top level hash to make on the shirts would be when the shirt is appropriate to wear. Divide the shirts into Work Shirts, Leisure Shirts, and Gym Shirts (insert other categories as you see fit). Then when it’s time to select a shirt for work in the morning, you don’t have to think about what COLOR you want to wear. Maybe then organize the work shirts by color.
We can do better by combining the above two schemes
Do double level hashing
1st Level do Occasion based Hashing
2nd Level do Color based hashing if reqd(if # of shirts are more than say 10 after 1st level hashing)
Besides that we can do caching of few shirts which are far frequently used(need to maintain a usecount for each) by keeping them before these occasion/color based divisions.
Double level hashing is a good idea. I would keep the first level of occasion based hashing, but I would do the second level hashing by dividing it into warm vs. cool colors. Then you:
1. Decide on the occasion.
2. Decide on the pants. If the pants are warm (i.e. most browns, beige, etc.), look in the warm section. If the pants are cool (i.e. most blues, blacks, whites, etc.) then look in the cool section.
This will ensure that you have a greater chance of matching outfits… call me dorky, but this is what I actually do.
I would afford a servant if I had a closet full of shirts, and his job would be to bring me the shirt of my choice. So I would use a ‘delegate model’ there. Not to get involved with the intricacies of the underlying system by using an interface to interact with it, and to utilize my time and thinking on more important things.
That is the easiest solution.
Is it a compulsion to use HASHING!!!!!
I dont think so.
I have only closet. I dont have lots other drawers to place the shirts. Then how hashing works for me.
The best solution is to do a LRU(Least Recently Used kind of thing). The closet is like a queue. Pop alway from the front and push from the end when ever you use the shirt. I think this is the most suitable and eficient answer as he did not mention any thing about the importance/color/other properties of shirts.
Call your mom. She will arrange it in such a fashion that you will never take more than a few seconds to find the shirt you want. I am not kidding - what she does will be hashing, but based on a very personal algorithm, that will be best suitable for you.
Simplest answer with deep meaning possible:
Imagine you have a closet full of shirts. It’s very hard to find “a shirt”.
Vulcan Logic suggests if you do not wanna be a programmer choose the simplest!.
Closet is full of shirts, we want “a shirt” meaning any shirt, put your arm there choose randomly, without thinking.
Build a relational database. Columns: primary key, color, occasion, use, etc. Consider ordering the key and shirts into some hierarchy of those categories (as suggested above) for visual searches; e.g. group by occasion, then subgroup by color, then assign keys in order, leaving spaces in keys after each group for new shirts. Write the key on the hanger for each shirt. As an alternative to visual search (consider warehouse closet), then search DB for shirt by: SELECT * FROM shirtTable WHERE color = ‘green’ AND occasion = ‘work’; Then simply look up key on hanger, which should be easy to find if ordered.
I Agree with hashing but there are some assumptions you have to make. If you want to hash usign hash function Color. Then, what if you just like to wear BLACK and WHITE shirts? The problem is that in this case hasing wont be efficient. you might resolve it by using either seperate chaining or open addressing. In any case, we are also making yet another assumption. If you use seperate chainining, then you are assuming that you have enough space inside each drawer of closet. IF you choose open addressing, then you dont have enough space in each drawer.
I guess the most logical thing to do is the MRU scheme, and stack the shirts accordingly.The ones not used should be put first, and then the top should be reached by the one being used the most. Also there can be multiple stacks (if not multiple drawers), so this time they can be according to occasions, and the most common occasions again at the most reachable spots. For special occasions’ shirts, use hangers, again in a horizontal stack fashion… So all in all, stack is the best data structure for such cases.. Also for searching, you have it stacked, still you can see all the shirts in one go (even the least used once) so no problem in searching at all… in a nutshell, a special stack, not being accessed just by the top element.
Take a graph sheet. Think all the 3d points which would be suitable as hangers, then extend the functionality such that it works for any arbitrary dimensions. Then apply the zeta-phi function to the coordinates. After having found the n-dimensional convex hull substitute the obtained figure into the eta variable of the zeta-phi function. This will give you a semi-linear equation. You need n more equations to solve the problem. Now bang your head against the wall- this will give you the required equations. Now you can happily arrange the shirts by applying the resultant function on the shirts.
Put all the shirts in hangers first irrespective properties and give number to each hanger.
maintain and excel sheet with fallowing columns.
Date of purchase
type ( formal/casual/spotrs)
remarks….etc as per req.
If u want some shirt , filter with properties and find the hanger number for appropriate shirt.
U can arrange the hanger as per ur conviniance…like but bundles of 10’s 100’s etc depending on quantity.