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

How do small intestinal epithelial and root hair cells function in nutrient procurement?
in the bakery a container of cookies i 4.55 and contains 13 servings the coins below equal 4.55 divide the coins into 13 eaqual groups
Why do most people begin a diet? A. to lower their blood pressure B. to raise their cholesterol C. to lose weight D. to avoid disease
an open square-based container is made by cutting 4 cm square pieces out of a piece of tinplate if the volume of the container is 120cm^3 find the size of the o
What is a biological desert
What is the complete predicate of the sentence The Art Institute is home to a famous collection of Impressionist art.
How did Native Americans come into conflict with the U.S. military?
divide 54 into the ratio 1 : 5
200 days from march 3 is
what number is a factor of 65