Question
Consider the following Python code snippet for binary search: def binary_search(arr, target): low = 0 high = len(arr) - 1 while low <= high: mid = (low + high) // 2 if arr[mid] == target: return mid elif arr[mid] < target: low = mid + 1 else: high = mid - 1 return -1 my_list = [10, 20, 30, 40, 50, 60] result = binary_search(my_list, 30) What is the value of mid in the first iteration of the while loop when searching for 30?
More Algorithms Questions
- Which is not true about minimum spanning tree?
- In a binary tree, if the number of leaf nodes is L, what is the number of nodes with two children?
- In which type of memory management does the operating system divide physical memory into fixed-size blocks?
- Which type of NAT (Network Address Translation) allows multiple private IP addresses to share a single public IP address?
- In Data Structures, which of the following algorithms uses the Divide and Conquer strategy?
- Which of the following is true for the time complexity of binary search?
- Recursive problems are implemented by
- Which of the following CPU scheduling algorithms is optimal for minimizing average waiting time but requires knowledge of future process execution times?
- Which algorithm uses a “divide and conquer” strategy?
- For a comparison-based sorting algorithm, which lower bound applies to the worst-case number of comparisons?
Hey! Ask a query
Please enter email id
The email must be a valid email address.
Please enter Mobile Number
Please enter valid Mobile Number
Please enter your Doubt
Think You're Ready for RBI Grade B?
RBI Grade B 2026 Phase 1 Memory Based Paper
- 200 Questions with Detailed Solutions
- Section-wise Coverage (GA, English, Quant & Reasoning)