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