l01 Intro
l01 Intro
Analysis of
Algorithms
By
Baidyanath Sou
Dept. of Computer science.
J.K. College
CHAPTER 1:
INTRODUCTION
• What is an Algorithm
• Steps in Designing and
Implementing an Algorithm
• Important Problem Types
• Fundamental Data Structures
2
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
• The same algorithm can be
represented in different ways
• Several algorithms for solving the
same problem
4
gcd(m,n)
3. if n % t = 0 return
t,
else goto
4
5
Understand the problem
Design an algorithm
Prove correctness
6
What does it mean to
understand the problem?
• What are the problem objects?
• What are the operations applied to the
objects?
Deciding on computational
means
• How the objects would be represented?
• How the operations would be
implemented?
7
Design an algorithm
Prove correctness
• Correct output for every
legitimate input in finite time
• Based on correct math formula
• By induction 8
Analyze the algorithm
10
Fundamental data structures
11
Fundamental data structures
13
Conclusion
• Algorithm classification
• By types of problems
• By design technique
• Design techniques
• a general approach to solving
problems
14