The Design and Analysis of Algorithms: by Anany Levitin
The Design and Analysis of Algorithms: by Anany Levitin
by Anany Levitin
Lecture notes prepared by Lydia Sinapova, Simpson College
CHAPTER 1: INTRODUCTION
What is an Algorithm
Steps in Designing and Implementing an Algorithm Important Problem Types Fundamental Data Structures
ALGORITHM
A
sequence of unambiguous instructions for solving a problem, i.e. for obtaining the required output for any legitimate input in
a finite amount of time
3
Important points
Non-ambiguity
Range of inputs
gcd(m,n)
while n 0 do r m mod n mn n r return m 1. t min (m ,n) 2. if m % t = 0 goto 3, else goto 4 3. if n % t = 0 return t, else goto 4 4. t t - 1 5. goto 2
5
Design an algorithm
Prove correctness
Analyze the algorithm Code the algorithm
6
What are the problem objects? What are the operations applied to the objects?
How the objects would be represented? How the operations would be implemented?
Design an algorithm
Build a computational model of the solving process
Prove correctness
Correct output for every legitimate input in finite time Based on correct math formula By induction
8
Coding
How the objects and operations in the algorithm are represented in the chosen programming language?
9
10
Graph representation: adjacency lists, adjacency matrix Tree representation: as graphs; binary nodes
12
Conclusion
Algorithm
By
classification
techniques
14