liveBook · Manning

Linear search

As explained in Latency

Linear search is a search algorithm that examines elements sequentially until it finds a target or reaches the end of a collection.

Linear search scans a collection sequentially, stopping when it finds the target or reaches the end. For an array of length n, its worst-case and average-case time complexity are O(n). section 7.2

Sequential array scan

A find function checks each value in order and returns true immediately on a match; otherwise, it returns false after the scan finishes. 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)
Figure 7.3: Illustration of algorithmic complexity in Big O notation for constant time O(1), logarithmic time O(log n), linear time O(n), and quadratic time O(n^2).

Compare linear growth with constant, logarithmic, and quadratic algorithmic growth as input size increases. section 7.2

How Latency covers it

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.
How it connects
Connects linear search with arrays, Big O notation, hash table lookups, and binary search trees.

Also explained in

Compare how 5 books explain linear search →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Latency. The section links point to the parts of the book it draws on.