dustinquiz7954 dustinquiz7954
  • 24-07-2020
  • Computers and Technology
contestada

A binary search function is searching for a value that is stored in the middle element of an array. How many times will the function read an element in the array before finding the value?

Respuesta :

JeanaShupp
JeanaShupp JeanaShupp
  • 30-07-2020

Answer: 1 time.

Explanation:

  • A binary function is also known as a half-interval search is a search algorithm to find the position of a given element x within a well-sorted array [].
  • Binary search compares the target value to the middle element of the array.
  • It ignores half of the elements just after one comparison.
  • it compares x with the middle element.

So, the function read an element one time in the array before finding the value.

Answer Link

Otras preguntas

Which symbol makes a true statement? –7.8? –7 a. = b. > c.
What is 46,491 rounded to the nearest ten thousand
What is the rule? 100 cm 1 m, 250 cm ? M, 1500 cm ? M
9,12,15,18,21,? if the pattern continues, what number likely comes next?
Metthew's cell phone plan charges $15 a monnth and 25 cents for every minute.If his bill for one month is $30.75,how many minutes did he use?Write and solve the
What is the correct classification of a mixture in which both a solid and a liquid are visible?
What is 0.56 as a fraction
Is 28/81 in simplest form
rosalinda got a payday loan for 2000 due in 2 weeks and she paid a 150 fee. what is the apr on rosalindas loan
Considering the European nations already had defined alliances, do you think that war would have been inevitable?