Answer:
Answer:
RANDY returns randomly, therefore any file within the index range with uniform distribution will have the recurrence relation to be
T(n) = T(n-i) + O(1)
With probability 1/n where i can range from 1 to n. Here, parameter n inside T(n) indicate the size of index range which will become (n-i) in next iteration.
Since i can range from 1 to n with probability 1/n, therefore the average case time complexity will be
T(n) =
Now solving T(n) = T(n/2)+O(1)
Will give T(n) = O(log n)
Therefore time complexity of this algorithm is O(log n).
Note that this is average time complexity because it's a randomized algorithm. In worst case, index range may just reduce by 1 and give time complexity of O(n) since in worst case T(n) = T(n-1)+O(1)
Step-by-step explanation: