CLRS Chapter: 1.1

Technical Sheet. Based on Introduction to Algorithms (Cormen et al., 4th Edition), Chapter 1 (Section 1.1: The role of algorithms in computing).


1. What is an Algorithm?

Informally, an algorithm is any well-defined computational procedure that takes some value, or set of values, as input and produces some value, or set of values, as output in a finite amount of time. Thus, an algorithm is a sequence of computational steps that transform the input into the output.

We can also view an algorithm as a tool for solving a well-specified computational problem. The problem statement describes, in general terms, the desired input/output relationship for instances of arbitrary size. The algorithm describes the specific computational procedure that achieves this relationship for all instances of the problem.


2. The Sorting Problem as a Paradigm

A fundamental and constant example in practice is sorting a sequence of numbers into monotonically increasing order. Its formal specification is as follows.

Input: a sequence of nn numbers ⟨a1,a2,…,an⟩\langle a_1, a_2, \dots, a_n \rangle.

Output: a permutation (reordering) ⟨a1′,a2′,…,an′⟩\langle a'_1, a'_2, \dots, a'_n \rangle of the input sequence such that:

a1′≤a2′≤⋯≤an′a'_1 \le a'_2 \le \dots \le a'_n

For example, given the input instance ⟨31,41,59,26,41,58⟩\langle 31, 41, 59, 26, 41, 58 \rangle, a correct sorting algorithm must return the sequence ⟨26,31,41,41,58,59⟩\langle 26, 31, 41, 41, 58, 59 \rangle.

Each specific input that satisfies the constraints of the problem is called an instance of the problem.


3. Correctness and Utility

An algorithm is correct if, for every instance provided as input, it halts in a finite time and produces the correct solution.

An incorrect algorithm may fail to halt on certain instances, or halt with an erroneous answer. Even so, an incorrect algorithm can be useful if its error rate is controlled, as is the case with some procedures for finding large prime numbers (Chapter 31). The primary focus of theory is on correct algorithms.

The specification of an algorithm can be written in natural language, as a computer program, or as a hardware design, as long as it describes the computational procedure unambiguously.


4. Real-World Applications

Algorithms are not limited to sorting. They underpin modern technological infrastructure across various domains:

  • Computational biology (Human Genome Project). Gene identification and DNA base-pair sequencing using techniques like dynamic programming (Chapter 14), optimizing time and resources.
  • Internet infrastructure. Management of large volumes of data, efficient routing in networks (Chapter 22), and high-speed search engines (Chapters 11 and 32).
  • E-commerce. Privacy through public-key cryptography and digital signatures based on number theory (Chapter 31).
  • Optimal resource allocation. Modeling industrial, commercial, and logistical problems through linear programming (Chapter 29).

Iconic Problems

  • Shortest path. Road maps are modeled as graphs to find minimum distances (Chapter 22).
  • Topological sorting. Sequences the dependencies of a mechanical design. The factorial n!n! makes brute-force enumeration of all orders unfeasible (Chapter 20).
  • Cloning and medical diagnosis. Clustering algorithms (Chapter 33) help distinguish cancerous tumors from benign ones.
  • Data compression. LZW and Huffman coding reduce file storage space (Chapter 15).
  • Signal processing. The Fast Fourier Transform (FFT, Chapter 30) converts a signal from the time domain to the frequency domain.

5. Data Structures, Design Techniques, and Difficult Problems

Data structures organize information so that accesses and modifications are efficient. There is no universal structure that serves all problems.

Design techniques go beyond a recipe book. Theory provides general methodologies: divide-and-conquer (Chapters 2 and 4), dynamic programming (Chapter 14), and amortized analysis (Chapter 16).

NP-Completeness

There are problems for which no efficient algorithm is known—that is, one that terminates in a reasonable amount of time. They form the class of NP-complete problems (Chapter 34).

If an efficient algorithm were found for a single NP-complete problem, one would exist for all of them.

Given a specific NP-complete problem—such as the traveling-salesperson problem—finding an exact optimal solution efficiently is not feasible. Instead, efficient approximation algorithms are designed (Chapter 35).


6. Alternative Models of Computation and Online Algorithms

The physical limits of power density halted the sustained increase in clock speed. Design shifted to multi-core processors and parallel computing. Taking advantage of them requires models designed for parallel tasks (Chapter 26).

Online Algorithms

Most classical algorithms assume that the entire input is available at the start. In many real-world scenarios, input arrives sequentially:

  • In a data center, jobs arrive and expire dynamically. The scheduler decides their execution without knowing the future.
  • Internet traffic is routed according to the current state of the network.
  • Medical triage prioritizes patients without knowing what ailments will arrive next.

Algorithms that receive their input progressively over time are called online algorithms. They are the subject of Chapter 27.