31.9k views
4 votes
The binary search algorithm ________. will have a maximum number of comparisons equal to the number of elements in the array will, normally, have the number of comparisons that is half the number of elements in the array is less efficient than the sequential search algorithm will cut the portion of the array being searched in half each time it fails to locate the search value

User Justasm
by
6.1k points

1 Answer

2 votes

Answer:

Hi!

The correct answer is:

The binary search algorithm will cut the portion of the array being searched in half each time it fails to locate the search value.

Step-by-step explanation:

Important! The elements of the array have to be in order to perform a binary search.

For example.

An array of 10 position. Each position represent the value of the element.

If you have to seek the number 1:

  • The first loop takes position 5 and evaluates. The value is greater than searched, discard the upper part of the array.

1 2 3 4 5 6 7 8 9 10

  • The second loop takes the position 3 and evaluates. The value is greater than searched, discard the upper part of the array.

1 2 3 4 --- 5 6 7 8 9 10

  • The third loop takes the position 2 and evaluates. The value is greater than searched, discard the upper part of the array.

1 --- 2 3 4 5 6 7 8 9 10

  • The fourth loop takes the position 1 and evaluates. The value is equal to searched, finish the seek.

1 --- 2 3 4 5 6 7 8 9 10

User So
by
5.3k points