Flowchart (ISO 5807)
Source code
TypeScript
function bsearch(a: number[], key: number): number {
let lo = 0, hi = a.length - 1;
while (lo <= hi) {
const mid = Math.floor((lo + hi) / 2);
if (a[mid] === key) return mid;
else if (a[mid] < key) lo = mid + 1;
else hi = mid - 1;
}
return -1;
}The editor opens with this code — change it and the chart redraws.
- Language
- TypeScript
- Constructs
- while + branching
- Topic
- Algorithms
- Formats
- Word, Visio, draw.io, PDF, SVG