Searching Algorithms: Binary Search - Implementations in C++ - Advanced Concepts

Download Q&A
Q. In a binary search algorithm, if the middle element is greater than the target, what should be done next?
  • A. Search the left half
  • B. Search the right half
  • C. Return the middle element
  • D. Increase the middle index
Q. What happens if the target value is not found in the array during binary search?
  • A. Returns the index of the closest value
  • B. Returns -1
  • C. Returns the last index
  • D. Throws an exception
Q. What is the result of binary search if the array is empty?
  • A. Returns 0
  • B. Returns -1
  • C. Returns null
  • D. Throws an error
Q. Which of the following best describes the space complexity of binary search?
  • A. O(n)
  • B. O(log n)
  • C. O(1)
  • D. O(n log n)
Q. Which of the following C++ functions can be used to implement binary search on a sorted array?
  • A. std::find
  • B. std::search
  • C. std::binary_search
  • D. std::linear_search
Showing 1 to 5 of 5 (1 Pages)
Soulshift Feedback ×

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

Not likely Very likely