Computer Science, asked by reema07, 5 months ago

write an algorithm to find the number using binary search​

Answers

Answered by yashsarate84
1

Answer:

Start with the middle element:

If the target value is equal to the middle element of the array, then return the index of the middle element.

If not, then compare the middle element with the target value,

If the target value is greater than the number in the middle index, then pick the elements to the right of the middle index, and start with Step 1.

If the target value is less than the number in the middle index, then pick the elements to the left of the middle index, and start with Step 1.

When a match is found, return the index of the element matched.

If no match is found, then return

Similar questions