Suppose you need to find a number in a list. You could check each entry until you find it or reach the end. That repeatable procedure is an algorithm: a finite sequence of steps for solving a specified problem. Its inputs, expected output, and behavior across different inputs should be clear. Finding the right answer matters, but so does the time and memory needed to get there. section 1.2 section 1.2.1
A practical way to design one is to ask:
- What are the inputs and the required output? For sorting, several algorithms can produce the same ordered list through different steps. section 1.2
- Does the procedure work for the full range of intended inputs, including edge cases? Start with a straightforward brute-force solution, then consider whether improving it is worthwhile. section 1.2.1
- What does it cost as the input grows? Compare time and memory use, and choose data structures that support the needed operations. section 1.3 section 1.4
Trace a search
With linear search, a match at the first position is the best case. If the value is absent, you must inspect all N entries: the worst case grows with the list. Walking through both cases tells you more than timing one convenient input. section 1.3
There is no universally fastest choice. A simpler, maintainable solution may serve a small system better than a clever one; at greater scale, the same steps may become a bottleneck. An algorithm can also have consequences beyond speed: in stable matching, the side that proposes receives a structural advantage, even though the procedure produces a stable match. section 1.0 section 2.1.3
Table 2.1 Time Complexity Analysis for N ranging from 10³ to 10⁶
|
N (Participants)
|
Performance
|
Time Complexity
|
|
N ≤ 10³ (1,000)
|
Instant response
|
O(10⁶)
|
|
N ≈ 10⁴ (10,000)
|
Fast (milliseconds)
|
O(10⁸)
|
|
N ≈ 10⁵ (100,000)
|
Borderline but with optimization feasible
|
O(10¹⁰)
|
|
N ≥ 10⁶ (1,000,000)
|
Impractical without heavy hardware modifications
|
O(10¹²)
|
The table illustrates how a quadratic algorithm’s work rises as the number of participants grows. Use the input size—not the complexity label alone—when judging whether an approach is practical. section 2.1.3


