Searching Algorithms: Binary Search

Download Q&A
Q. If the target value is not present in the array, what will binary search return?
  • A. The index of the closest value
  • B. The index of the first element
  • C. The index of the last element
  • D. -1
Q. In a binary search algorithm, what happens if the middle element is equal to the target?
  • A. Search continues in the left half
  • B. Search continues in the right half
  • C. Target is found
  • D. Search terminates immediately
Q. In binary search, if the target is less than the middle element, what should be the next step?
  • A. Search the right half
  • B. Search the left half
  • C. Return the middle element
  • D. Increase the middle index
Q. What is the average time complexity of binary search?
  • A. O(n)
  • B. O(log n)
  • C. O(n log n)
  • D. O(1)
Q. What is the main advantage of using binary search over linear search?
  • A. Binary search is easier to implement
  • B. Binary search works on unsorted arrays
  • C. Binary search is faster for large datasets
  • D. Binary search uses more memory
Q. What is the worst-case scenario for the number of comparisons made by binary search?
  • A. n
  • B. log n
  • C. n log n
  • D. 1
Q. Which of the following conditions must be true for binary search to work?
  • A. Array must be sorted
  • B. Array must be unsorted
  • C. Array must contain unique elements
  • D. Array must be of fixed size
Q. Which of the following is a prerequisite for applying binary search?
  • A. The array must be sorted
  • B. The array must be of even length
  • C. The array must contain integers only
  • D. The array must be in ascending order
Showing 1 to 8 of 8 (1 Pages)
Soulshift Feedback ×

On a scale of 0–10, how likely are you to recommend The Soulshift Academy?

Not likely Very likely