GATE DA 2026 | Question 31
Programming, Data Structures and Algorithms › Searching · NAT · 1 mark · Answer: 10
- Question 31Programming, Data Structures and Algorithmsnat1 markLet A be a sorted array containing 1000 distinct integers. You perform a recursive binary search on A to find an element y. Suppose each comparison checks whether the middle element computed during the current recursive step is equal to, less than, or greater than y. The maximum number of comparisons that may have to be performed if y is not an element of A is _______ . (Answer in integer)
Answer: 10
Solution
Each recursive step does one (three-way) comparison and then continues in a half of size at most :That is 10 steps before the range becomes empty. In general the worst case is comparisons. Answer: 10.
Attempt GATE DA 2026 in real GATE exam mode
Full paper with a timer, the GATE interface and a topic-wise analysis — free.
Create free account →