Interview Question
Software Engineer / Developers@ guest123
can u elaborate ur answer , at least give ur approach when answering a question
@ guest123
can u elaborate ur answer , at least give ur approach when answering a question
This is duplicate question, was seen sooooooo many times in amazon/MS question. What's wrong with this guy?
People should refrain from replying to posts that look like spamming or HOMEWORK!
I think instead of binary search we can do the following. Because we don't even know how much big is the array so how far would you travel to get a 1.
FindFirstOne(int arr[], int low, int max)
{
int h = abs(rand()) % max ;
if(arr[h] == 1)
FindFirstOne(arr, low, h);
else
FindFirstOne(arr, low + h, max);
}
Binary Search.
- Guest123 August 29, 2011