Eggs on slanted roof

Problem :

A rooster lays an egg at the very top of a slanted roof. Which side is the egg going to roll off on?

**Solution : **

Neither, roosters don’t lay eggs.

Eye color of bus driver

Problem :  You are the bus driver. At your first stop, you pick up 29 people. On your second stop, 18 of those 29 people get off, and at the same time 10 new passengers arrive. At your next stop, 3 of those 10 passengers get off, and 13 new passengers come on. On your fourth stop 4 of the remaining 10 passengers get off, 6 of those new 13 passengers get off as well, then 17 new passengers get on. [Read More]

The missing dollar

Problem Three travelers register at a hotel and are told that their rooms will cost $10 each so they pay $30. Later the clerk realizes that he made a mistake and should have only charged them $25. He gives a bellboy $5 to return to them but the bellboy is dishonest and gives them each only $1, keeping $2 for himself. So the men actually spent $27 and the bellboy kept $2 - what happened to the other dollar of the original $30? [Read More]

Get the matching pair out from 12 pair of black and white socks

**Problem : ** You have 12 black socks and 12 white socks mixed up in a drawer. It’s early in the morning and you don’t have any light to see the colors. How many socks must you pull out (blindly) to be sure of getting a matching pair? Solution :  3 socks. If the first sock is black, the second one could be black, in which case you have a matching pair. [Read More]

Move one DIGIT

Problem :

By moving one of the following digits, make the equation correct. 62 - 63 = 1

Answer: 

26 - 63 = 1 (In other words, 2x2x2x2x2x2, which equals 64)

Find the longest oscillating subsequence

Given the sequence of numbers find the longest oscillating subsequence Solution The oscillating sequence is the sequence, when the 2 adjacent numbers are either greater than or smaller than the current number. So, for example following is the oscillating sequence: 1, 7, 4, 6, 2 So, 7 is greater than both 1 and 4, 4 is less than both 4 and 6 and so on. Now, given the sequence of number we have to find the longest oscillating subsequence. [Read More]

Find the appropriate data structure

Lets see if you have solutions to the standard problems. Lets define the suitable data structures. Guess the data structues between the 2 data structures provided (in italics). Operations are Insert, DeleteMax, and DeleteMin. balanced tree or sorted doubly-linked list The balanced tree is better since all operations take O(log n) time. The sorted doubly-linked list is O(1) for DeleteMax and DeleteMin, but Insert is O(n); thus, the average time per operation is O(n). [Read More]

Common routing protocol

Problem Explain any common routing protocol in detail. For example: BGP, OSPF, RIP. Solution BGP: Border Gateway Protocol BGP is the core routing protocol of the Internet . When a BGP router first comes up on the Internet, either for the first time or after being turned off, it establishes connections with the other BGP routers with which it directly communicates. The first thing it does is download the entire routing table of each neighboring router. [Read More]

Compare and contrast IPv4 and IPv6

Problem Compare and contrast the IPv4 and IPv6 protocols. Solution IPv4 and IPv6 are the internet protocols applied at the network layer. IPv4 is the most widely used protocol right now and IPv6 is the next generation protocol for internet. Table Cell Table Cell IPv4 is the fourth version of Internet protocol which uses 32 bit addressing IPv6 is a next generation internet protocol which uses 128 bits addressing. [Read More]