πŸ” Search Algorithms

Watch linear and binary search work step by step. Understand when each algorithm shines β€” and when it doesn't.

Designed with the WJEC specification in mind
CS GCSE Β§1.4CS A-Level Unit 1CS A-Level Unit 3
βš™οΈ

Controls

Unchecked
Checking
In range
Midpoint
Eliminated
Found!
Generate an array and pick a target number to search for.
Comparisons0
Array Size15
StatusReady
πŸ“Š

Linear Search

Checks each element one by one from the start until the target is found or the end is reached.

Requirement: None β€” works on any array (sorted or unsorted).

When to use: Small arrays, unsorted data, or when the target is likely near the start.

Best
O(1)
Average
O(n)
Worst
O(n)
⚑

Binary Search

Repeatedly halves the search space by comparing the target with the middle element.

Requirement: Array must be sorted first.

When to use: Large sorted arrays. Massively faster than linear for big data sets.

Best
O(1)
Average
O(log n)
Worst
O(log n)