Computer Science · Algorithms
What is the output of the following recursive binary search code in Python on a sorted list arr = [1, 3, 5, 7, 9] when searching for 5? def binary_search(arr, target, low, high): if low > high: return -1 mid = (low + high) // 2 if arr[mid] == target: return mid elif arr[mid] > target: return binary_search(arr, target, low, mid - 1) else: return binary_search(arr, target, mid + 1, high) print(binary_search(arr, 5, 0, len(arr)-1))
- 12✓
- 21
- 33
- 44
Correct answer
2
Download Single Question PDF
Save this question and verified answer as a clean study sheet with live clickable link.
Share with Friends & Study Groups
Challenge your peer aspirants on WhatsApp or Telegram to solve this question!
Preparing for Computer Science?
Practice full-length mock tests with real exam timers, instant score analysis, and all-India ranking.
Want more practice questions on Algorithms?
Solve complete topic-wise tests with detailed solutions on GkGet.
Related Practice Questions
Recommended practice questions in Computer Science · Algorithms