Overview & Concept
Fibonacci Search is a comparison-based search algorithm for sorted arrays that divides the search interval using Fibonacci numbers. Unlike Binary Search which uses division by 2, Fibonacci Search uses only addition and subtraction to calculate split points, making it advantageous on low-power hardware lacking fast hardware division units.
How It Works
Fibonacci Split: Uses the identity Fib(k) = Fib(k - 1) + Fib(k - 2) to divide the search space.
Zero Division: Probe positions are calculated purely through addition and subtraction.
Asymptotic Efficiency: Achieves O(log n) time complexity matching binary search.
Step-by-Step Execution
Asymptotic Complexity Analysis
| Metric | Best Case | Average Case | Worst Case | Space Complexity |
|---|---|---|---|---|
| Complexity Bound | O(1) | O(log n) | O(log n) | O(1) |
| Explanation | Optimal input arrangement minimizing operations. | Expected time for uniformly distributed randomized inputs. | Adversarial degenerate conditions requiring full traversal. | Auxiliary memory allocated beyond original input size. |
Pseudocode & Invariants
procedure fibonacciSearch(A, target):
find smallest fibM >= n; fibMm2 = fib(M-2); fibMm1 = fib(M-1)
offset = -1
while fibM > 1:
i = min(offset + fibMm2, n - 1)
if A[i] < target: fibM = fibMm1; fibMm1 = fibMm2; offset = i
else if A[i] > target: fibM = fibMm2; fibMm1 = fibMm1 - fibMm2
else: return i
if fibMm1 and A[offset + 1] == target: return offset + 1
return -1- Fibonacci Bounding Invariant: Search space length corresponds to a Fibonacci number at each iteration.
Advantages & Disadvantages
Key Advantages
- •Requires only addition and subtraction: zero division or multiplication hardware required.
- •O(log n) time complexity.
Trade-offs & Limitations
- •More complex to implement than binary search.
Real-World Applications
Low-Power Embedded Microcontrollers
CPUs without hardware division units running fast sorted lookups.
Decision Guide: When to Use
Ideal Scenarios
- ✓When deploying on hardware architectures where CPU division operations are costly.
Consider Alternatives When
- ✕On modern x86/ARM processors where hardware division is instantaneous.
Explore Related Algorithms
Compare trade-offs and complexity across complementary tools in AlgoViz.