Menu BAR

FEEL FREE TO ASK ANY PROGRAM and please mention any error if you find it

28 Dec 2023

Algorithm - Binary Search

// Write an algorithm to do a binary search in an array

- Find the midpoint of the sorted array
- Compare the midpoint to the value of interest
- If the midpoint is larger than the value, perform binary search on right half of the array
- If the midpoint is smaller than the value, perform binary search on left half of the array
- Repeat these steps until the midpoint value is equal to the value of interest or we know the value is not in the array

No comments:

Post a Comment