AceTheInterview
Jobs in Pune | Work better in teams | Socialize with friends | Submit Q&A | Tell a friend
Search site for 

Top 100 Interview Questions & Answers in a convenient and easy to read book!

“I bought this guide a few days ago to prepare for my interview with Oracle. Many of the questions they asked me were from this guide. I found this book absolutely great!”

– Ravi, California

Read more comments...

Interview Questions And Answers RSS Feed

Answers »

  1. Submitted By: Mr. Google — October 17, 2006
    +31 votes
      + -

    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!

  2. Submitted By: madhu — December 8, 2006
    +7 votes
      + -

    arrage the shirts in the VIBGYOR order,and use binary search to get the short

  3. Submitted By: Kurt — December 15, 2006
    +29 votes
      + -

    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.

  4. Submitted By: Chetan — January 2, 2007
    +12 votes
      + -

    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.

  5. Submitted By: Sara — March 7, 2007
    +2 votes
      + -

    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.

  6. Submitted By: Ram — April 1, 2007
    -3 votes
      + -

    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.

  7. Submitted By: Sreeharsha Sarabu — June 12, 2007
    +2 votes
      + -

    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.

  8. Submitted By: Girish — June 16, 2007
    -1 votes
      + -

    A two fold approach.

    - Shirts that are more frequently used
    - Index by Color, size, make, quality of the shirt

    Use learn as you go concept for the first metric.

    Considering the circumstances, a linked list would work just fine. (Array would too, but re-ordering easier in LL)

  9. Submitted By: Sandy — July 9, 2007
    -5 votes
      + -

    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.

  10. Submitted By: gorkem — September 10, 2007
    -1 votes
      + -

    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.

  11. Submitted By: Al — September 19, 2007
    +1 votes
      + -

    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.

  12. Submitted By: clubberlang — November 9, 2007
    -2 votes
      + -

    Sometimes the easiest answer is the best-
    put all the shirts on hangers.
    There is difficulty in locating a shirt, not selecting a shirt

  13. Submitted By: CSGodFather — January 13, 2008
    +2 votes
      + -

    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.

  14. Submitted By: Ankit — February 7, 2008
    -1 votes
      + -

    Use a linked list.. Just remember which the first shirt is in the closet..and have a marking or a piece of paper in that shirt telling which is the next shirt.

  15. Submitted By: Molly — March 13, 2008
    not yet rated
      + -

    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.

  16. Leave an Answer/Comment

    To prove you're a person (not a spam script), type the security text shown in the picture. Click here to regenerate some new text.
    Click to hear an audio file of the anti-spam word

Our Sponsors
Our Sponsors
Contact Us | FAQ | Sitemap | Terms of Use | Privacy Policy | Tell a Friend

Copyright © 1999-2006 Jeeve Technologies LLC. All rights reserved.