Question: You are given an infinite array A in which the first n cells contain integers in sorted order and the rest of the cells are
You are given an infinite array A in which the first n cells contain integers in sorted order and the rest of the cells are filled with . You are not given the value of n. Design an algorithm that takes an integer x as input and finds a position in the array containing x, if such a position exists. Your algorithm should run in O(logn) time. Argue the correctness of your algorithm, and give analysis why your algorithm runs in O(logn) time.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
