Overview
Time complexity is a fundamental concept in computer science that helps us evaluate the efficiency of algorithms. By understanding how the runtime of an algorithm grows with input size, we can make informed decisions about which algorithms to use in different scenarios. This knowledge is crucial for...
Key Terms
Example: A recipe is an algorithm for cooking.
Example: O(n) means the runtime grows linearly with input size.
Example: In a linear search, the worst-case is when the item is not found.
Example: In a linear search, the best-case is when the item is the first element.
Example: Average-case for quicksort is O(n log n).
Example: Bubble sort and quicksort are common sorting algorithms.