Data Structures and Algorithms • C# examples
Big O, Big Omega, and Big Theta
Distinguish upper bounds, lower bounds, and tight asymptotic growth.
Concept
Big O gives an asymptotic upper bound, Big Omega a lower bound, and Big Theta a bound that is both upper and lower up to constant factors. These notations describe functions as input size grows; they do not measure machine speed or mean that one O(n) implementation always beats another.
How to approach it
Keep the dominant term, ignore constant multipliers for asymptotic comparison, and name assumptions about input distribution when discussing average behavior.
Complexity
For 4n² + 3n + 9, the asymptotic tight bound is Θ(n²).
C# example
// Two full passes: 2n operations are still linear growth.
for (int i = 0; i < n; i++) Work();
for (int i = 0; i < n; i++) Work();
Expected result or behavior
The total is 2n calls to Work; the constant factor does not change the Θ(n) class.
Practice exercise
Classify n log n + 4n + 20 and explain which term dominates for large n.
Key takeaway: Use asymptotic notation to compare growth, not to claim exact runtime.