Constant time, written O(1), describes an algorithm whose runtime remains the same as input size n grows. Big O compares growth rather than absolute execution time, so an O(1) operation is not necessarily faster for every small input. section 7.2
Constant-time choices matter in latency-sensitive code because replacing work that grows with n can prevent runtime from increasing rapidly. A hash table lookup is O(1) on average, while collisions can require a linear scan and produce O(n) worst-case behavior. section 7.2
Comparing lookup strategies
A linear search may inspect every element when the target is last, requiring O(n) steps. A hash table provides average O(1) lookup, but its operation must still be evaluated against worst-case behavior and input size. section 7.2
Figure 7.1 Illustration of algorithmic complexity in big O notation for constant time 𝑂(1), logarithmic time 𝑂(log𝑛), linear time 𝑂(𝑛), and quadratic time 𝑂(𝑛2)
Compare how constant, logarithmic, linear, and quadratic runtimes grow as input size increases. section 7.2







