Fibonacci Search is a comparison-based searching algorithm for sorted arrays that narrows the candidate range using Fibonacci numbers. Instead of dividing an interval into equal 50/50 halves like Binary Search, Fibonacci Search splits it asymmetrically in roughly a 38/62 golden-ratio proportion.
Because consecutive Fibonacci numbers satisfy F(m) = F(m − 2) + F(m − 1), every split uses pure addition and subtraction to compute probe indices. It preserves O(log n) time complexity while keeping probe offsets smaller when moving downward.
a = 0, b = 1, c = 1
while c < n:
a = b, b = c, c = a + b
offset = -1
while c > 1:
i = min(offset + a, n - 1)
if arr[i] < target:
offset = i
c = b, b = a, a = c - b
else if arr[i] > target:
c = a, b = b - a, a = c - b
else: return i
if b == 1 and offset + 1 < n:
if arr[offset + 1] == target:
return offset + 1
return -1
Control speed:
Metric / Operation | Complexity | Description |
|---|---|---|
| Best Case | O(1) | When the very first Fibonacci probe index matches the target. |
| Average Case | O(log n) | Reduces the search interval according to consecutive Fibonacci ratios (~1.618). |
| Worst Case | O(log n) | Requires at most ~1.44 log₂ n comparisons without any division or bit-shift operations. |
| Space Complexity | O(1) | Maintains only scalar variables for Fibonacci numbers (a, b, c) and offset. |
Binary Search splits the interval in half using division, whereas Fibonacci Search splits it at Fibonacci offsets using only addition and subtraction, maintaining O(log n) worst-case time.
When F(m) c shrinks to 1 with b == 1, one untested candidate element may remain at offset + 1, which must be compared directly against the target.
to join the discussion
Hand-picked resources to deepen your understanding
© 2025 See Algorithms. Code licensed under MIT, content under CC BY-NC 4.0