Question: The problem with Find - Index - 1 is that in the worst - case ( and not in expectation ) , it may actually
The problem with FindIndex is that in the worstcase and not in expectation it may actually never
terminate! For this reason, let us consider a simple modification to this algorithm as follows. FindIndex
A : n:
For j to n:
Sample i in n uniformly at random and if Ai mod output i and terminate;
otherwise, continue.
If the forloop never terminated, go over the array A one element at a time to find an index i with Ai
mod and output it as the answer.
Again, we skip the proof of correctness of this algorithm.
d What is the worstcase running time of FindIndexA : n What about its worstcase
expected running time? Remember to prove your answer formally
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
