Written byKrung Sinapiromsaran
July 2557
Aside from
You will need to learn using
T.H. Cormen et al. Introduction to Algorithms. MIT Press, 2001.
A lot of theorems and examples
Contains a lot of good references
Very useful for Computer Scientists
Need to have one (paper back or electronics)
K. Mehlhorn and P. Sanders. Algorithms and Data Structures: The Basic Toolbox. Springer, 2008.
B.R. Preiss. Data Structures and Algorithms with Object-oriented Design Patterns in Java. Wiley, 1999. (+ other Java-specific texts)
R. Sedgewick. Algorithms. Addison Wesley, 1988.
S.S. Skiena. The Algorithm Design Manual. Springer, 2008.
D.E. Knuth. The Art of Computer Programming. Addison Wesley, 1997. (In 3 volumes)
“If you think you’re a really good programmer, read Knuth’s Art of Computer Programming. You should definitely send me a resume if you can read the whole thing.”
Bill Gates
Muhammad ibn Mūsā al-Khwārizmī
“algorism” referred to rules of performing arithmetic using Arabic numerals
Evolved into “algorithm” and came to mean a definite procedure for solving a problem or performing a task
“the idea behind any reasonable computer program”
Something like a recipe, process, method, technique, procedure, routine etc
No formal definition has been accepted for all branches of Computer Science
According to our criteria, is the following statements valid algorithm?
According to our criteria, is the following statements valid algorithm?
According to our criteria, is the following statements valid algorithm?
According to our criteria, is the following statements valid algorithm?
According to our criteria, is the following statements valid algorithm?
According to our criteria, is the following statements valid algorithm?
According to our criteria, is the following statements valid algorithm?
According to our criteria, is the following statements valid algorithm?
In practice we want algorithms that are:
Q: Why don’t we always use English? Why don’t we program computers in English?
We will use a mixture of English and pseudocode.
The algorithm for finding the greatest common divisor given above can be expressed in pseudocode as follows:
As algorists, we need tools to:
A very common (and useful) informal way to specify a problem is to list its inputs and outputs:
Sorting:
Input:A sequence of $n$ numbers; $a_1, a_2, ..., a_n$
Output:A permutation, $i_1, i_2, ..., i_n$ of the input sequence such that
\[ a_{i_1} \leq a_{i_2} \leq ... \leq a_{i_n} \]
Robot arm must visit a set of contact points on a circuit board to solder each point Need to choose an order in which the contact points will be visited We want to minimise time taken, i.e. shortest path Shorter tour = faster production = cheaper to produce = more profit
Input: A set $P$ of $n$ points
Output: The shortest cycle tour that visits each point
Look encouraging
An instance where nearest neighbor gives a suboptimal solution
A better (optimal) solution for the same instance:
As algorists, we need tools to:
The theoretical study of computer program performance and resource usages.