Ugh, crash coursing on Big O notation.
Here are some common examples of Big O notations for different algorithms:
O(1): Constant time complexity, meaning the algorithm takes the same amount of time regardless of the input size. Examples of O(1) algorithms include accessing an element from an array or checking if a number is even or odd.
O(log n): Logarithmic time complexity, meaning the algorithm's runtime grows logarithmically with the input size. Examples of O(log n) algorithms include binary search and finding the height of a balanced binary tree.
O(n): Linear time complexity, meaning the algorithm's runtime grows linearly with the input size. Examples of O(n) algorithms include iterating through an array and finding the maximum or minimum value.
O(n log n): Log-linear time complexity, meaning the algorithm's runtime grows in proportion to n times the logarithm of n. Examples of O(n log n) algorithms include quicksort and mergesort.
O(n^2): Quadratic time complexity, meaning the algorithm's runtime grows in proportion to the square of the input size. Examples of O(n^2) algorithms include bubble sort and selection sort.
O(2^n): Exponential time complexity, meaning the algorithm's runtime grows exponentially with the input size. Examples of O(2^n) algorithms include the traveling salesman problem and the knapsack problem.