How would you define “algorithm” in your own words?
Have you encountered or engaged with an algorithm(s)? Describe your experience(s).
Can you think of a problem or task for which an algorithm(s) would be useful? Can you think of a problem or task for which an algorithm(s) would not be useful?
What do you think is the relationship between computers and algorithms?
What do you think the role of algorithms is in AI?
Can you place algorithms in a social context? That is, how are or should algorithms be used and viewed in our society?
Algorithms predate computers and even predate al-Khwarizmi. Examples of very early (perhaps ancient) algorithms include:
an ancient multiplication method that does not require a multiplication table,
Heron’s method (anticipated by Babylonian mathematicians) for computing the square root of a number (this is a special case of Newton’s method),
Sieve of Eratosthense algorithm for prime detection and Archimedes’ approximation of \(\pi\).
Let’s look integer division as an algorithm 1.
We can think of division with remainder as an algorithm.
\(b = aq + r\), \(0 \leq r < a\)
It is simply successive subtraction.
%%{
init: {
'theme': 'base',
'themeVariables': {
'primaryColor': '#BB2528',
'primaryTextColor': '#fff',
'lineColor': '#F8B229'
}
}
}%%
stateDiagram-v2
s1 --> s2
s2 --> s3 : Yes
s2 --> s4 : No
s4 --> s2
s1 : Input a and b
s2 : Is b-a negative
s3 : Output b
s4 : Replace b by b-a
Division with remainder leads to an even more interesting algorithm.
The Euclidean algorithm (EA) is an algorithm for finding the greatest common divisor (GCD) of two numbers.
Begin with two integers \(a\) and \(b\).
Find the remainder \(r\) in dividing \(b\) by \(a\).
If \(r\) is not zero, replace \(b\) with \(a\) and \(a\) with \(r\) and repeat.
%%{
init: {
'theme': 'base',
'themeVariables': {
'primaryColor': '#BB2528',
'primaryTextColor': '#fff',
'lineColor': '#F8B229'
}
}
}%%
stateDiagram-v2
s1 --> s2
s2 --> s3
s3 --> s4 : Yes
s3 --> s5 : No
s5 --> s2
s1 : Input a and b
s2 : Divide b by a get r
s3 : Is r zero?
s4 : Output a
s5 : Replace b w/ a, a w/ c
Let’s try it by hand.
Why does this algorithm stop, and why does the algorithm produce the GCD of \(a\) and \(b\)?
Relate the division and Euclidean algorithms with our initial discussion of algorithms.
What are the key features of the division and Euclidean algorithms that you think should extend to algorithms generally?
Are there any features of algorithms that are not represented by the division and Euclidean algorithms?
Note that we can think of the division and Euclidean algorithms in the following ways:
the division algorithm inputs two integers, does something with those integers, and returns an integer, i.e., the remainder;
the Euclidean algorithm inputs two integers, repeatedly applies the division algorithm, and returns an integer, i.e. the GCD.
Many algorithms can be viewed as a “machine” that inputs some information or data, transforms the input, and outputs some information or data.
Question: Can you think of a mathematical concept that takes input, does something, and returns an output?
This perspective on algorithms reminds me of functions (functions also appear in the context of computer science).
As we will discuss in detail later, a computer can be modeled as something that calculates functions. An important question is “which functions are computable”?
Before getting into all of that, let’s examine computer implementations of the division and Euclidean algorithms.
There are different approaches to AI including but not limited to
We will discuss these topics later in the course.
The role that algorithms play is different in different approaches to AI.
In some way or another, algorithms determine how AI systems process information, make decisions, or learn.
Algorithms, computation, and AI stemmed from investigations into mathematics and logic. Let’s touch upon this.
Das Entscheidungsproblem ist gelost, wenn man ein Verfahren kennt, das bei einem vorgelegten Ausdruck durch endlich viele Operationen die Entscheidung uber die Allgemeingultigkeit bzw. Erfullbarkeit erlaubt.1
The decision problem is solved if one knows a method that allows for the decision about the validity or feasibility through finitely many operations, given an presented expression.2

Entscheidungsproblem (decision problem) posed by Ackerman and Hilbert at the 1928 Bologna Congress
Mathematics of the 19th century highlighted the need for a better understanding of the foundations of mathematics. This was of major concern to Hilbert and he challenged the mathematics community to address the problems in the foundations of mathematics.
The Entscheidungsproblem arose from these challenges and essentially asked for a general procedure to determine the validity of a given mathematical statement.
The resolution of the Entscheidungsproblem produced a formal perspective on algorithms and as a side effect resulted in a framework for theorizing about computation.

Alan Turing derived a negative answer to the Entscheidungsproblem.
In the process, Turing developed a general concept now known as Turing Machines that is central to the theory of computation.
Turing machines will be a major topic in the next lecture on computation and computers.
Algorithms by Panos Louridas
Chapter 2 Algorithms: From Al-Khwarizmi to Turing and Beyond from Turing’s Revolution edited by Sommaruga and Strahm
The Emperor’s New Mind by Roger Penrose
Algorithms from the Book by Kenneth Lange
The Universal Computer: The Road from Leibniz to Turing by Martin Davis
The Honors Class: Hilbert’s Problems and Their Solvers by Ben Yandell