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 SQL function is used to count the number of rows in a table?
- What happens in a deadlock situation in an operating system?
- Which of the following is true about the time complexity of Merge Sort?
- What is the primary purpose of virtualization in cloud computing?
- Which of the following best describes the importance of digital signatures?
- Converting binary number 110001 to decimal will result in:
- Which algorithm finds the longest common subsequence (LCS) of two sequences?
- Which of the following is true about public-private key encryption in securing communications?
- Which algorithm uses a “divide and conquer” strategy?
- Which of the following SQL commands is a DML (Data Manipulation Language) command?
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)