Linear search
Linear search is a search technique that examines candidates sequentially until it finds a match or exhausts the collection.
Grokking Data Structures
Linear search examines the elements of a sequence one by one, typically from one end to the other, until the target is found or the sequence is exhausted.
- How it is used
- Supports searching arrays and linked lists when elements are examined sequentially until a match or endpoint appears.
- How deep it goes
- Explains scan behavior, sorted-array early termination, linked-list constraints, implementations, and O(n) analysis before contrasting binary search.
- Examples
- Uses sorted-array searches for targets 8 and 9, plus array and linked-list search implementations.
- What you can do after
- Build it from scratch by scanning arrays or linked lists, returning a match appropriately, and recognizing O(n) performance.
Classic Computer Science Problems in Swift: Essential techniques for practicing programmers
A linear search examines elements sequentially in their data-structure order until it finds the sought value or reaches the end.
- How it is used
- Uses sequential inspection to determine whether a value occurs in an unsorted or otherwise directly traversable collection.
- How deep it goes
- Defines the scan, implements it for codons and generic Swift collections, and identifies O(n) worst-case work.
- Examples
- Uses a gene of codons, the target codon ACG, a generic Swift function, and million-element timing exercises.
- What you can do after
- Build it from scratch for codons or generic Equatable arrays, then compare its timing with binary search.
Clojure: The Essential Reference
A linear search examines collection elements sequentially until a matching element is found or the collection is exhausted.
- How it is used
- Clarifies how to perform explicit element scans instead of misusing contains? on vectors.
- How deep it goes
- Defines sequential scanning and contrasts some, .contains, and contains? without developing implementation internals.
- Examples
- Uses some on a vector, an equality predicate for nil, vector index checks, and Java .contains calls.
- What you can do after
- Apply it via some or .contains when selecting an explicit element or substring scan.
Read how Clojure: The Essential Reference explains linear search →
Grokking Simplicity
A search algorithm that examines elements sequentially until a matching element is found or the collection is exhausted.
- How it is used
- Uses sequential array search to separate item lookup from cart operations and expose opportunities for reuse.
- How deep it goes
- Works through extraction, return values, layer structure, and reuse, then defers a more general loop version.
- Examples
- Uses shopping-cart lookup, item removal, membership testing, and price updates as concrete search clients.
- What you can do after
- Apply it via a reusable indexOfItem() function that returns an index or null for cart-based operations.
Latency
Linear search is a search algorithm that examines elements sequentially until it finds a target or reaches the end of a collection.
- How it is used
- Uses sequential scanning to find a target in an array and frame runtime growth in algorithmic complexity.
- How deep it goes
- Defines scanning behavior and average and worst-case O(n), but stops short of detailed implementation analysis.
- Examples
- Uses array target search, active orders as input-size intuition, and a sequential find function.
- What you can do after
- Apply it by scanning a collection and estimating average and worst-case search growth.
High Performance Unity Game Development
A search technique that examines elements sequentially until it finds a match or reaches the end.
- How it is used
- Handles dictionary hash collisions by locating a free slot during insertion or scanning for a key during lookup.
- How deep it goes
- Explains insertion and lookup scans and their repeated cost, without detailing implementation code.
- Examples
- Uses dictionary insertion and lookup after hash collisions to illustrate sequential scans.
- What you can do after
- Understand how collisions can trigger sequential scans during dictionary insertion and lookup.
Read how High Performance Unity Game Development explains linear search →
Vibe Engineering
Linear search is a search algorithm that examines elements sequentially until a matching element is found or the collection is exhausted.
- How it is used
- Uses linear search as a performance baseline when evaluating lookup strategies against expected traffic and collection size.
- How deep it goes
- Compares runtime tradeoffs and stops short of detailing linear-search implementation internals.
- Examples
- Uses 10,000 accounts, AccountFinder strategies, and JMH comparisons as concrete performance examples.
- What you can do after
- Evaluate lookup strategies by supplying traffic and data-size assumptions, then verifying claims with benchmarks.
Also covered in
What to know first
- arrayAn array is an ordered collection of elements organized in one or more dimensions and accessible by position or index.
- loopA loop is a programming-language control-flow construct that repeatedly executes a block of instructions according to an iteration rule or continuation condition.
- key-value pairA key-value pair is a data association in which a key identifies or provides access to its corresponding value.
- MapA map is an associative data structure that stores key-value associations and supports retrieving values by key.
Related concepts
- binary searchcontrasts with · Binary search is an algorithm that repeatedly halves an ordered search interval to locate a target or determine its position or boundary.
- linear time complexitymeasured by · Linear time complexity is an asymptotic running-time bound that grows at most proportionally to the input size, or combined input sizes, ignoring constant factors.
- containsimplemented by · Contains is a membership-query operation that reports whether a specified value, key, element, or substring occurs in a container or collection.
- findimplemented by · A find operation searches a collection for the first element or entry matching a value or predicate and returns it, or indicates that no match exists.
- k-d treecontrasts with · A k-d tree is a binary space-partitioning tree that organizes points in multidimensional space by recursively comparing coordinate dimensions.
- linked listuses · An ordered sequence of elements stored in separate nodes connected by links or references rather than in one contiguous storage region.
Questions about linear search
What is linear search?
Linear search is a search technique that examines candidates sequentially until it finds a match or exhausts the collection.
Which Manning books explain linear search?
Grokking Data Structures, Classic Computer Science Problems in Swift: Essential techniques for practicing programmers, Clojure: The Essential Reference, Grokking Simplicity, Latency, High Performance Unity Game Development and Vibe Engineering.
What should I know before learning linear search?
Manning books that teach linear search usually introduce array, loop, key-value pair and Map first.
What is the difference between linear search and binary search?
Linear search is a search technique that examines candidates sequentially until it finds a match or exhausts the collection. Binary search is an algorithm that repeatedly halves an ordered search interval to locate a target or determine its position or boundary.
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.






