oscarsanchez5297 oscarsanchez5297
  • 06-09-2019
  • Computers and Technology
contestada

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

Respuesta :

ExieFansler ExieFansler
  • 11-09-2019

Answer:

10.

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.

Answer Link

Otras preguntas

Suddenly I felt a misty consciousness as of something forgotten- a thrill of returning thought; and somehow the mystery of language was revealed to me. A. Concl
define secessionist movement​
how do you get a Mach number?
Error Analysis: Explain the error(s) that the scholar made below. Then, solve correctly.
Order the following from least to greatest: -0.3, 4/5, -5/12, 0.92​
Pests have always been a nuisance for farmers. The use of pesticides dramatically improved the success of crops; however, it has been found that some insects ar
according to the line plot what is the total number of the dog toys​
why are segmented worms called “annelids”?
which ratios form a proportion?​
what is equivalent to (4×10^-5)+(2×10^-5)÷(3×10^7)​