No. It can be applied to any positive number N.
The solution above splits the numbers by the least significant bit,
choose the group with missing number, and then drop the last bit and
continue.
In this way the set [0,N] is partitioned (almost) evenly into 2 groups:
{2k | k=0,1,...,N/2} and {2k+1 | k=0,1,...(N-1)/2}
and the one with missing number is no more than N/2 numbers.
So the total number of fetch_bit operations is no more than 2N.
On 2011-1-17 15:43, juver++ wrote:
@awesomeandroid
Your solution for Q1 is wrong. It can be applied only for such numbers
N = 2^k, so number should power of 2.
--
You received this message because you are subscribed to the Google
Groups "Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.
--
You received this message because you are subscribed to the Google Groups "Algorithm
Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.