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
- What is normalization in the context of databases?
- Which layer of the OSI model is responsible for providing end-to-end communication services and ensures complete data transfer?
- Consider a directed acyclic graph (DAG). The problem of finding the longest path in a DAG (with edge weights) can be solved in:
- Which algorithm uses a priority queue to repeatedly pick the next closest vertex?
- Which of the following sorting algorithms is a non-comparison-based sort?
- Which graph traversal method uses a queue?
- In which type of memory management does the operating system divide physical memory into fixed-size blocks?
- For a binary search algorithm to work efficiently, what must be true about the input data?
- Which SQL function is used to count the number of rows in a table?
- Which type of firewall operates at the application layer of the OSI model and inspects incoming and outgoing data packets?
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)