Sort the array with 0s and 1s

You are given an Array of N size. It contains 0s and 1s only. You have to arrange all 0s before all 1s and you are not allowed to travel more than once through the array.

Find a cycle in a linked list..

How would you find a cycle in a linked list?

Store all receiving samples..

Given that you are receiving samples from an instrument at a constant rate, and you have constant storage space, how would you design a storage algorithm that would allow me to get a representative readout of data, no matter when I looked at it? In other words, representative of the behavior of the system to date.

Multiply by 7..

Multiple by 8 without using multiplication or addition. Now do the same with 7.

Count number of 1s..

Count the number of set bits in a number. Now optimize for speed. Now optimize for size.

Circular linked list..

Implement an algorithm to insert a node into a circular linked list without traversing it.

Find ratio..

If you have two buckets, one with red paint and the other with blue paint, and you take one cup from the blue bucket and poor it into the red bucket. Then you take one cup from the red bucket and poor it into the blue bucket. Which bucket has the highest ratio between red and blue? Prove it mathematically.

Measure exactly 4 quarts..

If you had an infinite supply of water and a 5 quart and 3 quart pail, how would you measure exactly 4 quarts?

Break the gold bar..

You've got someone working for you for seven days and a gold bar to pay them. The gold bar is segmented into seven connected pieces. You must give them a piece of gold at the end of every day. If you are only allowed to make two breaks in the gold bar, how do you pay your worker?

Minimum attempts..

You have a bucket of jelly beans. Some are red, some are blue, and some green. With your eyes closed, pick out 2 of a like color. How many do you have to grab to be sure you have 2 of the same?

Find odd jar...

You have 4 jars of pills. Each pill is a certain weight, except for contaminated pills contained in one jar, where each pill is weight + 1. How could you tell which jar had the contaminated pills in just one measurement?

Why is a manhole cover round?

Why is a manhole cover round?

Minimum number of weighings..

You have eight balls all of the same size. 7 of them weigh the same, and one of them weighs slightly more. How can you find the ball that is heavier by using a balance and only two weighings?

Now, Assume that we don't know whether the odd ball is heavier or lighter. Find the number of minimum number of weighings required to find the odd ball.

Check the above two conditions when the number of balls are 12.

Proportion of boys to girls..

In a country in which people only want boys, every family continues to have children until they have a boy. if they have a girl, they have another child. if they have a boy, they stop. what is the proportion of boys to girls in the country?

100 married couples

Every man in a village of 100 married couples has cheated on his wife. Every wife in the village instantly knows when a man other than her husband has cheated, but does not know when her own husband has. The village has a law that does not allow for adultery. Any wife who can prove that her husband is unfaithful must kill him that very day. The women of the village would never disobey this law. One day, the queen of the village visits and announce that at least one husband has been unfaithful. What happens?

Cutting rectangular cake

How do you cut a rectangular cake into two equal pieces when someone has already taken a rectangular piece from it? The removed piece an be any size or at any place in the cake. You are only allowed one straight cut.