Knowledge Card - Big O Notation

Big O Notation

  1. Purpose: Describes the growth rate of an algorithm's runtime.

    • Example: Linear search is O(n), binary search is O(log n).
  2. 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).
  3. Importance: Helps choose efficient algorithms for large datasets.