Question: 5, (a) (10%) Your friend, John, is holding an integer array A 1..n], and he tells you that the array is sorted, and contains al

 5, (a) (10%) Your friend, John, is holding an integer array

5, (a) (10%) Your friend, John, is holding an integer array A 1..n], and he tells you that the array is sorted, and contains al the integers from 0 to n except one. John challenges you to find the missing integer. He allows you to ask him questions in the form: "What is the jth bit of Ai]?" and he is going to answer you honestly. So, you can vary the values of i and j in each question you ask him. Design an efficient algorithm to find out the missing integer using O(log2 n) questions (b) (10%) Now, John has changed the input, and the array A becomes unsorted. Design an algorithm using O(n) questions to find out the missing integer

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!