Searching Algorithms: Binary Search - Higher Difficulty Problems

Download Q&A
Q. If the array is sorted in descending order, can binary search still be applied?
  • A. Yes, with modifications
  • B. No, it cannot be applied
  • C. Yes, without any changes
  • D. Only for specific cases
Q. If you have a sorted array of 1000 elements, how many iterations will binary search take at most?
  • A. 10
  • B. 20
  • C. 30
  • D. 40
Q. In a binary search, if the target value is not present in the array, what will be the return value?
  • A. -1
  • B. 0
  • C. null
  • D. the index of the closest value
Q. In binary search, how do you calculate the middle index?
  • A. (low + high) / 2
  • B. (low + high) / 2 + 1
  • C. (low + high) / 2 - 1
  • D. low + (high - low) / 2
Q. What happens if the middle element in binary search 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 fails
Q. What is the worst-case scenario for the number of comparisons made by binary search on an array of size n?
  • A. n
  • B. log n
  • C. n log n
  • D. 1
Showing 1 to 6 of 6 (1 Pages)
Soulshift Feedback ×

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

Not likely Very likely