## A Bit of History: Donald Knuth and the Art of Computer Programming
![[Donald-Ervin-Knuth.jpg]]
[Donald Knuth](https://en.wikipedia.org/wiki/Donald_Knuth) is a renowned computer scientist whose most famous work is a series of books called [The Art of Computer Programming](https://en.wikipedia.org/wiki/The_Art_of_Computer_Programming). In 1962, he wrote a 7-book outline for it, and as of 2024 has not quite finished book 4.
In these books he gives detailed mathematical analyses of many important algorithms. In Volume 1 (published in 1967), finding the max value among a list of numbers was one of problems that Knuth studied. Let's look at it here. While the algorithm is simple, determining its performance has unexpected depth.
## Finding the Max
Finding the maximum value among a list of numbers is a common and practical problem:
> **The Max of a List**: Given values $v_0, v_1, \ldots, v_{n-1}$ with $n > 0$, the **max** of the list is a value $v_i$, with $0 \leq i < n$, such that $v_i \geq v_j$ for all $j$ in $0, 1, \ldots , n-1$.
The definition allows for the possibility that the max occurs 2 or more times. Also, *nothing* is assumed about the order of the elements: $v_0, v_1, \ldots, v_{n-1}$ could be in *any* order at all.
## Basic Solution
The basic algorithm for solving this problem checks each element of the list to see if it's bigger than the values that have been checked earlier.
In this algorithm, $k$ is the index of the *max value found so far*. The notation $x \leftarrow y$ means assignment, i.e. `x = y` in C++:
- Step 1: $k \leftarrow 0$
- Step 2: if $v_1 \geq v_k$ then $k \leftarrow 1$
- Step 3: if $v_2 \geq v_k$ then $k \leftarrow 2$
- Step 4: if $v_3 \geq v_k$ then $k \leftarrow 3$
- ...
- Step $i +1$: if $v_i \geq v_k$ then $k \leftarrow i$
- ...
- Step $n$: if $v_{n-1} \geq v_k$ then $k \leftarrow n-1$
- Step $n + 1$: return $k$
Since $n