Question: You are given an infinite array A[] in which the first n cells contain integers in ascending order and the rest of the cells are
![You are given an infinite array A[] in which the first](https://s3.amazonaws.com/si.experts.images/answers/2024/09/66db38483ca2f_82366db38479a1a9.jpg)
You are given an infinite array A[] in which the first n cells contain integers in ascending order and the rest of the cells are filled with infinity. You are not given the value of n. Describe a divide \& conquer algorithm that takes an integer x as input and finds a position in the array containing x, if such a position exists, in O(logn ) time. (If you are disturbed by the fact that the array A has infinite length, assume instead that it is of length n, but that you don't know this length, and that the implementation of the array data type in your programming language returns the error message "infinity" whenever elements A[i] with i>n are accessed.) A complete solution will (a) describe your algorithm in English (no pseudocode), (b) provide a justification of correctness (why does this approach work?), and (c) state and analyze its runtime in Big O notation, including a recurrence relation for it, if relevant
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
