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

I need help to solve it
Women are at a greater risk of depression than men partially because women are more likely to
In a formal letter, the date should be shown directly above the...
A survey of 125 randomly selected kids ages 13 to 16 found that 33 of them play soccer, 27 of them play basketball, 24 of them play baseball, 28 of them play so
Which of the following organisms does not rely on krill as a major food source? Adelie penguins Leopard seal Humpback whale Squid
A need to survive and grow pushes media businesses towards localism.
Do you think preston brooks punishment was reasonable why or why not
What is the difference between dorsiflexion and plantar flexion?
According to Newton's 1st law of motion, which object below will not change speed or direction of motion without an additional force acting on it? a soccerball
What is the primary purpose of us military bases around the world?