Computer Science, asked by ArjunTomar234, 1 year ago

A programmer writes a program to find an element in the array answer

Answers

Answered by firingsquad
0

Binary Search is performed on a sorted array.


For each iteration,

1. It first finds the mid element's value.

2. Comparison of X and mid values.

If value(X) = value(mid) then

You've found the number. EXIT.

If value(X) > value(mid) then

Perform Binary Search on second half of array.

If value(X) < value(mid) then

Perform Binary Search on first half of array.

Therefore the answer is 40.

hope it helps

Similar questions