The Design and Analysis of Algorithms - Ch01
The Design and Analysis of Algorithms - Ch01
Analysis of Algorithms
by Anany Levitin
• What is an Algorithm
• Steps in Designing and Implementing an
Algorithm
• Important Problem Types
• Fundamental Data Structures
ALGORITHM 3
• 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
Important points 4
• Non-ambiguity
• Range of inputs
• The same algorithm can be
represented in different ways
• Several algorithms for solving the
same problem
gcd(m,n) 5
4. t ← t - 1
5. goto 2
6
Understand the problem
Design an algorithm
Prove correctness
Deciding on computational
means
• How the objects would be represented?
• How the operations would be implemented?
Design an algorithm 8
Prove correctness
• Correct output for every legitimate
input in finite time
• Based on correct math formula
• By induction
Analyze the algorithm 9
Efficiency: time and space
Simplicity
Generality: range of inputs, special cases
Optimality:
no other algorithm can do better
Coding
How the objects and operations in the
algorithm are represented in the chosen
programming language?
Important problem types 10
• Sorting
• Searching
• String processing
• Graph problems
• Combinatorial problems
• Geometric problems
• Numerical problems
Fundamental data structures 11
• Algorithm classification
• By types of problems
• By design technique
• Design techniques
• a general approach to solving problems