What is "Big O notation" and "time complexity"?
Code examples demonstrating the following complexity classes:
- O(1) - constant time (inserting elements at the beginning of a linked list)
- O(n) - linear time (summing up all elements of an array)
- O(n²) - quadratic time (sorting an array with Insertion Sort)
- O(log n) - logarithmic time (finding an element within a sorted array using binary search)
- O(n log n) - quasi-linear time (sorting an array with Quicksort)
The code belongs to this article: