MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

ALGORITHMS

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
What is the main disadvantage of a binary search compared to a linear search?
A
It requires the data to be in order
B
It requires more memory
C
It does not execute as quickly with larger data sets
D
Not all CPUs are capable of executing the algorithm
Explanation: 

Detailed explanation-1: -Linear search can be suitable for searching over an unsorted array. whereas, Elements in the array need to be in sorted order for binary search. The binary search algorithm uses the divide-and-conquer approach, it does not scan every element in the list.

Detailed explanation-2: -The biggest problem with a binary search is that you can only use this if the data is sorted into an order.

Detailed explanation-3: -The main advantage of using binary search is that it does not scan each element in the list. Instead of scanning each element, it performs the searching to the half of the list. So, the binary search takes less time to search an element as compared to a linear search.

Detailed explanation-4: -Sorted Data: Linear search has no requirement for the data to be sorted. Binary search can only be implemented on sorted data. Efficiency: Binary search is faster (in terms of scan cycles) and more efficient compared to linear search especially for larger data sets.

Detailed explanation-5: -binary search algorithm is not efficient when the data elements are more than 1000.

There is 1 question to complete.