Question:

Given an array $A = \{15, 23, 27, 32, 45, 49, 60\}$ and key = 49, what are the mid values (corresponding array elements) in the first and second levels of recursion?

Show Hint

Track indices and recalculate mid for each recursive call in binary search.
Updated On: June 02, 2025
  • 32 and 49
  • 32 and 23
  • 27 and 49
  • 27 and 45
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is A

Solution and Explanation

Binary search midpoints:
- Level 1: \(\text{mid} = \lfloor (0+6)/2 \rfloor = 3 \Rightarrow A[3] = 32\)
- 49>32 → search right half (4 to 6)
- Level 2: \(\text{mid} = \lfloor (4+6)/2 \rfloor = 5 \Rightarrow A[5] = 49\)
Was this answer helpful?
0
0

TS PGECET Notification