Create a flowchart for a binary search algorithm
About the framework
This ten-node flowchart searches for a target in a sorted array. It initializes low to zero and high to n minus one, checks whether low is at most high, and calculates a midpoint. A matching value returns mid; otherwise, a second comparison chooses which bound to change.
The two update steps set low to mid plus one or high to mid minus one, then loop to the bounds check. When the interval is exhausted, the flow returns -1. The midpoint box writes (low+high) / 2 without stating integer rounding, so that detail needs clarification in a code-oriented version.
Use the diagram for a hand trace with a small sorted array. Record low, high, and mid after each iteration, and try both present and absent targets. The example returns a matching index but has no special branch for locating the first duplicate.
What's included
Binary Search Algorithm Flowchart
✦ Free preview · Sign in to use
Frequently asked questions
The example assumes a sorted array. Its comparisons narrow the interval using that order; sorting is not a step in the diagram.
The box does not state rounding. For an index-based version, make integer rounding explicit, for example with low + floor((high-low)/2).
The bound updates repeat until low is greater than high. The No branch from low <= high then returns -1.
Free to start. No credit card required.