abreazeale4071 abreazeale4071
  • 22-10-2017
  • Mathematics
contestada

How many comparisons are needed for a binary search in a set of 64 elements?

Respuesta :

meerkat18
meerkat18 meerkat18
  • 02-11-2017

Let f(n) be the number of comparisons required to search for an element in a search sequence of size n. Then from the binary search algorithm we can have f(n) = f(n/2) + 2, where n is even.

 

The number of comparisons needed for a binary search in a set of 64 elements is f(64).

f(64) = f (32) + 2

= f(16) + 2 + 2

= f(8) + 2 + 2 + 2

= f(4) + 2 + 2 + 2 + 2

= f(2) + 2 + 2 + 2 + 2 + 2

= f(1) + 2 + 2 + 2 + 2 + 2 + 2

= 0 + 2 + 2 + 2 + 2 + 2 + 2+ 2

f(64) = 14

Answer Link

Otras preguntas

What do you think has caused the black live movement to gain or lose momentum
What type of government does india have? What are its pros and cons?
linnaeus classification system is based on physical similarities. what type of information has been used more recently to determine relationships between organi
Describe the process of how a business is "incorporated"
The width of the rectangle shown below is 8 inches (in.). The length is 3 feet (ft.).
Factor Completely.3g^2-78g+75
Which amendment says newpapers may print articles that speak against the government
A rocket fires two engines simultaneously. One produces a thrust of 725 N directly forward, while the other gives a 513-N thrust at 32.4° above the forward
Your coin collection totals $24. You have an equal number of nickels, quarters, and half-dollars. How many coins do you have? Please show your work.
Solve pls thank you​