Knowledge Card - Big O Notation
Big O Notation
-
Purpose: Describes the growth rate of an algorithm's runtime.
- Example: Linear search is O(n), binary search is O(log n).
-
Common Notations:
- O(1): Constant time (e.g., accessing an array element).
- O(n): Linear time (e.g., traversing a list).
- O(n²): Quadratic time (e.g., nested loops).
- O(log n): Logarithmic time (e.g., binary search).
-
Importance: Helps choose efficient algorithms for large datasets.