- 2071 Magh · 3 marks
Big-O notation with properties
Short answer
Big-O: f(n) ≤ c·g(n) for large n. Properties: reflexivity (f = O(f)), transitivity, constant factors absorbed, sum rule (O(max(g₁,g₂))), product rule, polynomial order, and growth hierarchy O(1) ⊂ O(log n) ⊂ O(n) ⊂ O(n log n) ⊂ O(n²) ⊂ O(2ⁿ).
Explain big-O notation with its properties.
Big-O notation: f(n) = O(g(n)) if there are positive constants c and n₀ with f(n) ≤ c·g(n) for all n ≥ n₀. It gives an upper bound on the growth rate. Example: 2n + 10 ≤ 3n for n ≥ 10, so 2n + 10 = O(n).
Properties
- Reflexivity: f(n) = O(f(n)).
- Transitivity: if f = O(g) and g = O(h), then f = O(h).
- Constant factor: O(c·f(n)) = O(f(n)) for c > 0.
- Sum rule: if f₁ = O(g₁) and f₂ = O(g₂), then f₁ + f₂ = O(max(g₁, g₂)).
- Product rule: f₁ · f₂ = O(g₁ · g₂).
- Polynomial: if f(n) = aₖnᵏ + ... + a₁n + a₀, then f(n) = O(nᵏ).
- If f(n) ≤ g(n) for all large n, then O(f) ⊆ O(g).
- Growth order: O(1) ⊂ O(log n) ⊂ O(n) ⊂ O(n log n) ⊂ O(n²) ⊂ O(2ⁿ).
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Define Big O, Omega and Theta · Data Structure and Algorithm, chapter 9 · asked 4×
- Big-O and Big-Omega with curves · Data Structure and Algorithm, chapter 9 · asked 4×
- Big-Oh significance and limitation · Data Structure and Algorithm, chapter 9