Technical Interview

Tips, questions, answers and puzzles at
www.technical-interview.com

Thursday, February 8, 2007

Imagine you have a closet full of shirts....

Imagine you have a closet full of shirts. It’s very hard to find a shirt. So what can you do to organize your shirts for easy retrieval?

8 comments:

  1. 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.

    ReplyDelete
  2. Ask more questions...I would only keep the best 10, donate to charity the ones that still good. Through away the bad ones...
    Why use hashing when I need only a few shirts?

    ReplyDelete
  3. Though separating out the shirts by color is a good scheme, why cant we also apply the fabric of the shirt as the condition. So all cotton shirt would be stacked toether, all silk shirts together and so on..
    Or a mixture of colorand fabric could be a scheme too. after separating the color, sort them fabric wise. This would ensure that search is limited.

    So suppose C1, C2 .... Cn are the colors and each C(i) has type of fabric F(j). Then after F(1) is complete , keep a tag to mark the end or the beginning of the new fabric type F(j+1).

    ReplyDelete
  4. The problem asks how "you" would do it. Well for me, I would arrange the shirts into some sort of cache. The shirts that I use all the time would be closest to the closet entry. The shirts that I never wear would be hiding at the back.

    Realistically though, I think that the shirts that get worn the most would be either in the wash, or hanging over a door or chair. The shirts that end up in my closet are shirts that i don't wear much (that or I must have had a cleaning day), because when my favorite shirts do get into the closet they are not normally there for long.

    ReplyDelete
  5. What I do is to put the clean shirts from the dish washer on the same end each time; as the clothes are not worn, they get pushed back. So the popular shirts are at the clean end and the shirts I can give away and not miss are clustered at the old end.

    ReplyDelete
  6. Dewey Decimal System. Using the the clothes brand name.

    ReplyDelete
  7. Open your closet door and grab a shirt. If's full of shirts anyways so you don't have to dig through pants and stuff to get to your shirts. You grab one, wear it for the day, then throw it into the laundry basket.

    ReplyDelete
  8. 1. Seperate the shirt by this type t-shirt, half-sleeve, full-sleeve.
    2. Order each shirt type by its color like dark color to light. Done.

    ReplyDelete