Tuesday, August 01, 2006

Algorithmic Puzzle - Nuts and bolts

There are some nuts and some bolts in random order.

1) You cannot compare nuts with nuts and bolts with bolts.
2) It is guaranteed that a nut will fit in one or more bolts.

Now you have to sort both nuts and bolts separately in minimum complexity.

2 comments:

Perspective Inc. said...

whaaaat???
:-)

kart said...

1) "You cannot compare nuts with nuts and bolts with bolts." - Means, you cannot compare two bolts (or two nuts) and say which is bigger.

2) "It is guaranteed that a nut will fit in one or more bolts." - Means, you can check if a bolt fits into a particular nut or not.

To simplify things, let us say there are 10 nuts and 10 bolts. You need to sort them into two groups - one containing nuts and the other bolts - each arranged in ascending order of their sizes.