Two ball bounce problem Two I had an interview, where they have asked me a physics puzzle.
The question was,
If two balls have been dropped at the same time from same height. suppose Ball A will start bouncing by 10% of reducing its height from its very previous bounce. And Ball Bwill start bouncing by 20% of reducing its height from its very previous bounce. Then how many times they will cross each other?
I have answered him as,
Definitely, Ball B bounce less than Ball A. So, in this context
if Ball-B starts its bounce from height = x.
Then if I will apply this into a program,
int cnt = 0;//Pseudo Code
if(x != 0)
{
x = x * 20 / 100;
 cnt++;
}

So, final value of cnt = number of times they will cross each other.
But after this I was thinking that, this many not be correct answer as in first drop,
the Ball-A might have bounced of height x + (x- (height bounced by Ball-B)).
So, it is not necessary that they might have crossed each other.
Please me understanding this puzzle.
 A: Your code only measures how many times ball $B$ can bounce before the precision of the computer is unable to distinguish its height from zero.  This seems like an entirely different question from the one you are asked!
A second point is that the question says (in my interpretation) that each bounce of ball $B$ is 80% of the height of the previous one.
So in my interpretation ball $A$ is bouncier than ball $B$.
You seem to agree with this at one point, put then your code suggests that each bounce of ball $B$ is 20% the height of the previous one.
Notice that each ball bounces infinitely many times, with the bounce times forming a convergent geometric series.  This is because the time that a bounce takes to complete is proportional to the speed at the start of the bounce, which is reduced by a constant factor each time.
Denote the time of the first bounce by $t=0$. Let $t_A$ denote the sum of the bounce times for ball $A$, or equivalently the time at which $A$ completes all of its (infinitely many) bounces and begins sitting still. 
Similarly, let $t_B$ denote the sum of the bounce times for ball $A$, or equivalently the time at which $B$ completes all of its (infinitely many) bounces and begins sitting still. 
Note that $t_B < t_A$, so ball $B$ has finished bouncing while ball $A$ has bounced only finitely many times.  All of the crossings must therefore happen in the time interval $[0,t_B]$.  Let $t_0 = 0, t_1,t_2,\ldots,t_n \le t_B$ list in increasing order the times at which ball $A$ hits the ground during this interval.
For each bounce $[t_i,t_{i+1}]$ of ball $A$, it crosses paths with ball $B$ at most twice: At most once on the way up (because at any given height it is moving faster than ball $B$ is) and at most once on the way down (for the same reason.)  Therefore an upper bound on the number of crossings is given by $2n$.
Because ball $A$'s height in the middle of one of its bounces $[t_i,t_{i+1}]$ is higher than ball $B$ can ever be during that time interval, the only way that there could be fewer than two crossings during the time interval $[t_i,t_{i+1}]$ is in the "degenerate case" that ball $B$ is on the ground at time $t_i$ or at time $t_{i+1}$.  This happens at the beginning of $A$'s first bounce at $t = 0$.  I'll leave it up to you to calculate $t_B$, $n$, and $t_1,\ldots,t_n$, and to see whether this "degenerate case" ever happens again.
