1.6 Classes of functions
Understanding Time Complexity
Types of Time Complexities
- The discussion begins with an overview of various time complexities, starting with constant time complexity, denoted as O(1). This indicates that the execution time remains constant regardless of input size.
- It is emphasized that even if a function's output is a large number (e.g., 2, 5, or 5000), it still qualifies as constant time complexity since it does not depend on the size of the input (n).
- The next type discussed is logarithmic time complexity (O(log n)), which can be based on different logarithm bases. This complexity suggests that the algorithm's performance improves significantly as input size increases.
- Moving forward, linear time complexity (O(n)) is introduced. Examples include functions like f(n) = 2n + 3 and f(n) = n/5000 + 6, all classified under linear due to their degree being one.