Algorithms: Philip W. L. Fong
Algorithms: Philip W. L. Fong
Algorithms
Chapter 1
Algorithms
Philip W. L. Fong
Readings
Outline
1 Introduction
2 Algorithms
Grading Scheme
Outline
1 Introduction
2 Algorithms
Computational Problems
Computational Problems
Example of Problem/Instance
Example (Sorting)
The sorting problem can be stated as follows:
Input: a sequence ha1 , a2 , . . . an i of “keys”
The keys are assumed to be comparable (i.e., supporting
the < operator, which is a binary relation that is irreflexive,
asymmetric, and transitive).
Output: a permutation hb1 , b2 , . . . , bn i of the input
sequence that is in ascending order
Here is an instance of the sorting problem:
h3, 1, 4, 2, 5i
h1, 2, 3, 4, 5i
Philip W. L. Fong Chapter 1: Algorithms
Introduction
Algorithms
Algorithms
Definition (Algorithm)
An algorithm is a platform-independent and language-agnostic
presentation of a computational procedure. It is typically
designed to solve a given computational problem.
Keyword: “solve”
Remark
I will use the criteria of the previous 3 slides to grade your work.
key
ii
I
j
sorted prefix
wtf
processed
Philip W. L. Fong Chapter 1: Algorithms
Introduction
Algorithms
Remarks
Exercise
What are the strengths and weaknesses of this presentation of
insertion sort?