Roadmap › Coding Round Practice (DSA in C#) › Module: Foundations
Lessons in this course (14)

1. Big-O notation

Basic★ Must knowLesson 1 of 14

Big-O describes how time or memory grows as input size n grows (worst case, ignoring constants).

Big-ONameExample
O(1)ConstantArray index, dictionary lookup (average)
O(log n)LogarithmicBinary search, balanced BST
O(n)LinearSingle loop, linear search
O(n log n)LinearithmicMerge sort, Array.Sort (introsort)
O(n²)QuadraticNested loops, bubble sort
O(2ⁿ)ExponentialNaive recursive Fibonacci, all subsets
O(n!)FactorialAll permutations

C# collection costs: List<T>.Add amortised O(1), Insert(0) O(n), Contains O(n); Dictionary/HashSet add/lookup O(1) average; SortedDictionary O(log n); Array.Sort/List.Sort O(n log n).

Interview tip: always state both time and space complexity, e.g. "O(n) time, O(n) extra space for the dictionary."