Constant time
Constant time is an asymptotic running-time bound, conventionally denoted O(1), that remains bounded independently of input size.
Algorithms Every Programmer Should Know
A time complexity, denoted O(1), that remains bounded independently of input size.
- How it is used
- Compares how operations scale with input size when selecting algorithms and data structures.
- How deep it goes
- Defines O(1) through simple operations and qualifies hash-map performance with a worst-case collision scenario.
- Examples
- Uses indexed array access, swapping two numbers, and deque-backed queue operations.
- What you can do after
- Evaluate/understand whether an O(1) claim applies to one operation or to a larger algorithm.
Read how Algorithms Every Programmer Should Know explains constant time →
Fabulous Adventures in Data Structures and Algorithms
Constant-time complexity is computational complexity in which an operation takes a bounded amount of time independent of input size.
- How it is used
- Distinguishes the costs of individual operations from whole algorithms and sequences of operations.
- How deep it goes
- Defines O(1) and contrasts worst-case, amortized, and deferred costs, without deriving formal bounds.
- Examples
- Uses queue operations, Hughes-list reversal, and Fisher–Yates swaps to contrast constant and linear costs.
- What you can do after
- Evaluate operation costs by distinguishing worst-case bounds, amortized bounds, and deferred work.
Read how Fabulous Adventures in Data Structures and Algorithms explains constant time →
Practices of the Python Pro
Constant time is an asymptotic performance classification in which execution time remains bounded independently of the number of inputs.
- How it is used
- Frames constant time as a target for analyzing and designing high-performance software.
- How deep it goes
- Defines O(1), explains upfront-computation trade-offs, and distinguishes constant-time lookup from O(n) iteration.
- Examples
- Uses Python dictionaries, sets, lists, and a favorite-colors file to contrast constant-time operations with linear work.
- What you can do after
- Apply it via Python dictionaries and sets to make repeated item access or membership checks independent of input size.
Read how Practices of the Python Pro explains constant time →
Advanced Algorithms and Data Structures
Constant time is a running-time bound independent of the input size, up to a fixed bound.
- How it is used
- Uses constant-time bounds to compare data-structure operations and justify performance choices under explicit parameter assumptions.
- How deep it goes
- Defines O(1) through heap, hashing, key-length, and amortization cases, but stops short of formal proofs.
- Examples
- Uses bounded heap updates, Bloom-filter insertion and lookup, LRU-cache operations, and inefficient LFU-list updates as examples.
- What you can do after
- Evaluate whether an operation is O(1) by identifying growing inputs, fixed bounds, key-length limits, and amortization.
Read how Advanced Algorithms and Data Structures explains constant time →
Clojure: The Essential Reference
Constant time is an asymptotic complexity in which execution time does not grow with input size.
- How it is used
- Characterizes fixed-cost function creation, invocation, bitwise operations, and lazy-sequence generation.
- How deep it goes
- Distinguishes setup from consumption, invocation arity, hardware dependence, caching, and retained-head memory costs.
- Examples
- Uses fnil, bitwise operations, powerset generation, repeatedly, random values, and a large lazy sequence.
- What you can do after
- Evaluate complexity claims by separating eager setup, deferred consumption, supported arity, and retained data.
Read how Clojure: The Essential Reference explains constant time →
Latency
Constant time is an algorithmic growth class in which required operations remain independent of input size.
- How it is used
- Uses growth classification to guide low-latency algorithm choices and identify work worth eliminating.
- How deep it goes
- Defines O(1), contrasts growth classes, and distinguishes average from worst-case lookup behavior without deriving implementation internals.
- Examples
- Uses linear array search, hash-table lookup, a growth comparison figure, and an operations-complexity table.
- What you can do after
- Evaluate algorithm choices by separating growth behavior, absolute runtime, average cases, and worst-case cases.
Python Workout: 50 ten-minute exercises
An asymptotic time complexity that remains bounded independently of the number of elements processed.
- How it is used
- Frames constant time as a way to reason about dictionary and hash-based lookup performance.
- How deep it goes
- Explains bounded growth through an office analogy and dictionary mechanics, while acknowledging collisions without detailing their implementation.
- Examples
- Uses alphabet-indexed office searches and Python dictionary retrieval to illustrate constant-time access.
- What you can do after
- Evaluate whether direct lookup remains bounded as the collection grows, including the effect of collisions.
Read how Python Workout: 50 ten-minute exercises explains constant time →
Python Workout, Second Edition
Constant time is a computational complexity in which execution time does not grow with the size of the input.
- How it is used
- Frames constant time as the performance characteristic motivating hash-based lookup and Python dictionaries.
- How deep it goes
- Defines O(1), illustrates its scaling behavior, and sketches hashing and collisions while deferring several implementation details.
- Examples
- Uses numbered offices, alphabetic initials, duplicate surnames, and d['a'] = 1 to demonstrate direct lookup and collisions.
- What you can do after
- Apply it via Python dicts by relating key hashing to immediate storage-slot lookup and recognizing collision handling.
Read how Python Workout, Second Edition explains constant time →
Also covered in
- Elixir in Action, Third Edition
- Grokking Algorithms, Second Edition
- Grokking Data Structures
- Julia as a Second Language
What to know first
- arrayAn array is an ordered collection of elements organized in one or more dimensions and accessible by position or index.
- MapA map is an associative data structure that stores key-value associations and supports retrieving values by key.
- loopA loop is a programming-language control-flow construct that repeatedly executes a block of instructions according to an iteration rule or continuation condition.
- linked listAn ordered sequence of elements stored in separate nodes connected by links or references rather than in one contiguous storage region.
Related concepts
- Mapmeasured by · A map is an associative data structure that stores key-value associations and supports retrieving values by key.
- listmeasured by · list is a PersistenceLayer method that retrieves bookmark records in a specified ordering.
- lookup operationmeasures · A lookup operation locates or retrieves data associated with a specified key, identifier, index, or other locating value.
- performancekind of · Performance is a measure of how effectively a person, process, model, or system achieves its objectives, including qualities such as output quality, speed, and resource efficiency.
- setused by · A set is a collection of distinct elements in which membership, rather than order or duplicate occurrences, defines the collection.
Questions about constant time
What is constant time?
Constant time is an asymptotic running-time bound, conventionally denoted O(1), that remains bounded independently of input size.
Which Manning books explain constant time?
Algorithms Every Programmer Should Know, Fabulous Adventures in Data Structures and Algorithms, Practices of the Python Pro, Advanced Algorithms and Data Structures, Clojure: The Essential Reference, Latency, Python Workout: 50 ten-minute exercises and Python Workout, Second Edition.
What should I know before learning constant time?
Manning books that teach constant time usually introduce array, Map, loop and linked list first.
What is constant time a kind of?
Constant time is a kind of performance. Performance is a measure of how effectively a person, process, model, or system achieves its objectives, including qualities such as output quality, speed, and resource efficiency.
What is constant time also called?
Constant time is also called O(1).
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.







