Session-1 & Session-2
Session-1 & Session-2
Analysis of Algorithms
Understanding Algorithms
◼ Correctness
◼ Efficiency
◼ Asymptotic Complexity, O() notation
◼ Modelling
◼ Graphs, Data Structures, Decomposing the Problems
◼ Techniques
◼ Divide and Conquer, Greedy, Dynamic Programming
2
Motivation
3
Abstract Level
4
Efficiency ?
◼ N cities F direct flights
◼ Dependency
5
CHAPTER 1: INTRODUCTION
◼ What is an Algorithm
◼ Steps in Designing and Implementing
an Algorithm
◼ Important Problem Types
◼ Fundamental Data Structures
6
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
7
Important points
◼ Non-ambiguity
◼ Range of inputs
◼ The same algorithm can be
represented in different ways
◼ Several algorithms for solving
the same problem
8
gcd(m,n)
4. t ← t - 1
5. goto 2
9
Understand the problem
Design an algorithm
Prove correctness
10
What does it mean to understand
the problem?
◼ What are the problem objects?
◼ What are the operations applied to the objects?
11
Design an algorithm
14
Fundamental data structures
Binary trees
17
Conclusion
◼ Algorithm classification
◼ By types of problems
◼ By design technique
◼ Design techniques
◼a general approach to solving problems
18