31.8k views
4 votes
Which element would the search element be compared to first, if abinary search were used on the list above?

4
35
44
98

User Chandima
by
7.2k points

1 Answer

3 votes

Answer:

35

Step-by-step explanation:

Binary search is more efficient than linear search,time complexity of binary is 0(logn) where as linear's 0(n).In binary search we search from the middle of the array,whereas in linear we start with index 0 until the last.

4

35

44

98

List contains 4 elements, for finding the middle element we will divide by 2 .

4/2=2 so at the index 2 -35 is present ,we will start checking from 35.

User Omroy
by
7.5k points