SearchingAnimated
Fibonacci Search
Binary-search variant that splits by Fibonacci numbers using only + and −.
Time
O(log n)
Extra space
O(1)
Use it for
Sorted data where division is costly.
How it works
- Like binary search but splits the list using Fibonacci numbers instead of halving, so it only uses addition and subtraction.
- Find the smallest Fibonacci number F(k) ≥ n.
- Probe index offset + F(k−2). If the value is too small, move the offset there and step down one Fibonacci number; if too big, step down two.
- Stop when the Fibonacci number reaches 1; check the last candidate.
- O(log n) time.
Watch it run
Loading animation…