Question: Bob is sending a sorted array A containing n unique numbers to Alice. Specifically, there is no number in A that appears more than once.

Bob is sending a sorted array A containing n unique numbers to Alice. Specifically, there is no number in A that appears more than once. Prof. G is a malicious attacker who messes up the communication in the following way:

splits the array A at an index x

creates a new array B by taking second half of A (i.e., from index x+1 to n-1) followed by the first half of A (i.e., from index 0 to x)

sends B to Alice

For e.g., if A = [5, 9, 17, 29, 32, 46, 78, 83, 96] and B = [78, 83, 96, 5, 9, 17, 29, 32, 46], then x = 5.

Provide Alice with an O(log n) time algorithm to figure out the index x, where the array A was split. Write a pseudo-code.

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!