ChatDiagram
Flowchart · Algorithm

Binary Search Algorithm Flowchart

Binary search finds a target in a sorted array by halving the search window. It computes the midpoint, compares it to the target, and eliminates the half that cannot contain it. If low exceeds high, the element is absent.

類型 流程圖標準 Sugiyama layered DAG + orthogonal routing引擎 schematex-flowchart更新時間 2026/5/27
Binary Search Algorithm
Drawing preview
需求

“Flowchart of binary search: set low and high, loop while low ≤ high, compute mid, return mid if it matches the target, otherwise move low or high, and return -1 when the loop ends.”

接著試試Turn it into the recursive versionAdd a check for an empty array
這張圖裡有什麼

看懂背後的決策。

01Loop condition "low <= high" is the sentinel

when low crosses high, -1 is returned.

02

Two separate update branches (sethi, setlo) make the asymmetric narrowing explicit and verifiable.

03Mid computed as (low + high) / 2

in production code use low + (high - low) / 2 to prevent integer overflow.

Extend to binary search on answer space (binary search on result) for optimization problems.

更多類似內容

同類型的其他範例。

瀏覽所有 流程圖 範本 →