You are given an array of 2n + 1 numbers. Out of these 2n + 1 numbers, 2n are duplicate. You are supposed to find the number which is not duplicate.
Everything about algorithms and algorithms for everything.
You can change one character in the above program to make it working. There are three such solutions existing. So have fun with the C syntax and more than one way to accomplish task.#include <stdio.h>
int main(int argc, char *argv[])
{
int i, n = 20;
for ( i = 0; i < n; i--)
printf("-");
return 0;
}
The king summoned the best mathematicians in the kingdom to the palace to find out how smart they were. The king told them: "I have placed white hats on some of you and black hats on the others. You may look at, but not talk to, one another. I will leave now and will come back every hour on the hour. Every time I retur, I want those of you who have determined that you are wearing white hats to come up and tell me immediately". As it turned out, at the nth hour every one of the n mathematicians who were given white hats informed the king that she knew she was wearing a white hat. Why ?There are several variations of the above problem but the underlying theme is same. The solution for the above problem is given in the book whose link is given above. The problem is a fantastic application of the use of mathematical induction in proving certain conjecture. In our problem, the conjecture is at nth hour all the mathematicians wearing white hats will know about it.