Alorithms · Class 12 · CBSE · Science Computer Science
Which condition is necessary before applying binary search to an array?
Practice question from Alorithms (Class 12 · CBSE · Science Computer Science), with the correct answer and a step-by-step solution.
easy · MCQ · Q-203DC4
Which condition is necessary before applying binary search to an array?
- A.The array must contain only integer values.
- B.The array must be sorted.Correct answer
- C.The array must have an even number of elements.
- D.The array must not contain duplicate values.
Solution
Binary search repeatedly compares the target with the middle element and eliminates half of the search space. This elimination is valid only when the elements are arranged in sorted order.
More from Alorithms
- Explain why binary search cannot generally be applied directly to an unsorted array. Also state the worst-case time complexity of linear se…
- What is the array after the first complete pass of selection sort in ascending order on [29, 10, 14, 37, 13]?
- Which statement correctly describes the worst-case time complexity of insertion sort and the situation in which it performs efficiently?
- Explain why merge sort is generally preferred over selection sort for sorting a large collection of data. State the time complexity of both…
Practise more Computer Science
Sign up free for adaptive practice on this chapter, with instant feedback and hints on every question.
Start practising freeFree to start · No credit card needed