171k views
1 vote
If a binary search is applied to an array with 1024 elements, in the worst case, the main loop executes, approximately, _____.

1 Answer

0 votes

Answer:

10.

Step-by-step explanation:

Binary search divides the array to be search each in half according to the value of the element.

The worst case time complexity of binary search is O(logN).

In this case the time complexity will come out to be log₂(1024)=10.

So the binary search can divide this array in half maximum of 10 times.

Hence the main loop will executes 10 times.

User Nmiculinic
by
7.8k points