1. Engineering
  2. Computer Science
  3. b prove that your algorithm is correct hint prove that...

Question: b prove that your algorithm is correct hint prove that...

Question details

3. (30 pts) Professor Flitwick asks you to help him with some arrays that are slumped. An array A is slumped if A1.i has the property that, for some C > 0, Alj +1A-C for 1 j < i, and A[i.n] has the property that, for some D0 where C D, Ali + 1] = AGI + D for i-j < n. Using his wand, Flituick writes the following slumped array on the board A [7,3,-1,-5,0, 10, 15, 20, 25], as an erample. (a) Flitwick found that one of his slumped arrays had an identical adjacent value (i.e., A[j] = Ali +11) and no longer trusts any of his slum ped arrays. Write a recursive algorithm that takes asymptotically sub-linear time to ensure that there are no identical adjacent elements in A

(b) Prove that your algorithm is correct. (Hint: prove that your algorithm’s correctness follows from the correctness of another correct algorithm we already know.)

(c) Now consider the multi-slumped generalization, in which the array contains k local minima, i.e., it contains k subarrays, each of which is itself a slumped array. Let k = 2 and prove that your algorithm can fail on such an input.

(d) Suppose that k = 2 and we can guarantee that neither local minimum is closer than n/3 positions to the middle of the array, and that the “joining point” of the two singly-slumped subarrays lays in the middle third of the array. Now write an algorithm that tests A for identical adjacent values in sublinear time. Prove that your algorithm is correct, give a recurrence relation for its running time, and solve for its asymptotic behavior.

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution