SlideShare a Scribd company logo
The Design and
Analysis of Algorithms
by Anany Levitin
Lecture notes prepared by Lydia Sinapova,
Simpson College
2
CHAPTER 1: INTRODUCTION
 What is an Algorithm
 Steps in Designing and Implementing
an Algorithm
 Important Problem Types
 Fundamental Data Structures
3
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
4
Important points
 Non-ambiguity
 Range of inputs
 The same algorithm can be
represented in different ways
 Several algorithms for solving
the same problem
5
gcd(m,n)
while n ≠0 do
r ← m mod n
m ← n
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
6
Understand the problem
Decide on computational means
Exact vs approximate solution
Data structures
Algorithm design technique
Design an algorithm
Prove correctness
Analyze the algorithm
Code the algorithm
7
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?
8
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
9
Analyze the algorithm
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?
10
Important problem types
 Sorting
 Searching
 String processing
 Graph problems
 Combinatorial problems
 Geometric problems
 Numerical problems
11
Fundamental data structures
Linear data structures
 Array
 Linked list
 Stack
 Queue
Operations: search, delete, insert
Implementation: static, dynamic
12
Non-linear data structures
 Graphs
 Trees : connected graph without cycles
Rooted trees
 Ordered trees
Binary trees
Graph representation: adjacency lists,
adjacency matrix
Tree representation: as graphs; binary nodes
Fundamental data structures
13
Fundamental data structures
Sets, Bags, Dictionaries
 Set: unordered collection of distinct elements
Operations: membership, union, intersection
Representation: bit string; linear structure
 Bag: unordered collection,
elements may be repeated
 Dictionary: a bag with operations search,
add, delete
14
Conclusion
 Algorithm classification
By types of problems
By design technique
 Design techniques
a general approach to solving problems

More Related Content

PPT
Higher Maths 1.1 - Straight Line
PPT
Sistem bilangan-real-1
DOCX
(8.5.1) soal dan pembahasan gradien, matematika sltp kelas 8
PPT
Unit 1 chapter 1 Design and Analysis of Algorithms
PPT
L01 intro-daa - ppt1
PDF
Algorithm chapter 1
Higher Maths 1.1 - Straight Line
Sistem bilangan-real-1
(8.5.1) soal dan pembahasan gradien, matematika sltp kelas 8
Unit 1 chapter 1 Design and Analysis of Algorithms
L01 intro-daa - ppt1
Algorithm chapter 1

Similar to l01-intro (3).ppt (20)

PPTX
a581a6a2cb5778045788f0b1d7da1c0236f.pptx
PPT
chapter 1
PDF
Lecture 1 (bce-7)
PPTX
Chapter one
PDF
Artificial Intelligence - Anna Uni -v1.pdf
PPT
Data Structures and Algorithm Analysis
PPTX
Analysis Framework, Asymptotic Notations
PPTX
PPT
Lecture 01-2.ppt
PPT
introegthnhhdfhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhppt
PDF
week1-module1-introduction-merged.pdf
PDF
Design & Analysis Of Algorithm
PDF
Computer Science (CSC 102) Lecture 1.pdf
PDF
Design and Analysis Algorithms.pdf
PPTX
Data_structures_and_algorithm_Lec_1.pptx
PPTX
Data_structures_and_algorithm_Lec_1.pptx
PPT
467719275-Lecture-01 designe and alg.ppt
PPT
UnitI (1).ppt
PPT
ANALYSIS-AND-DESIGN-OF-ALGORITHM.ppt
PPTX
8.unit-1-fds-2022-23.pptx
a581a6a2cb5778045788f0b1d7da1c0236f.pptx
chapter 1
Lecture 1 (bce-7)
Chapter one
Artificial Intelligence - Anna Uni -v1.pdf
Data Structures and Algorithm Analysis
Analysis Framework, Asymptotic Notations
Lecture 01-2.ppt
introegthnhhdfhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhppt
week1-module1-introduction-merged.pdf
Design & Analysis Of Algorithm
Computer Science (CSC 102) Lecture 1.pdf
Design and Analysis Algorithms.pdf
Data_structures_and_algorithm_Lec_1.pptx
Data_structures_and_algorithm_Lec_1.pptx
467719275-Lecture-01 designe and alg.ppt
UnitI (1).ppt
ANALYSIS-AND-DESIGN-OF-ALGORITHM.ppt
8.unit-1-fds-2022-23.pptx
Ad

Recently uploaded (20)

PDF
Insiders guide to clinical Medicine.pdf
PPTX
GDM (1) (1).pptx small presentation for students
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Pre independence Education in Inndia.pdf
PPTX
Pharma ospi slides which help in ospi learning
PPTX
Institutional Correction lecture only . . .
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Complications of Minimal Access Surgery at WLH
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Classroom Observation Tools for Teachers
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
Computing-Curriculum for Schools in Ghana
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Insiders guide to clinical Medicine.pdf
GDM (1) (1).pptx small presentation for students
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Pre independence Education in Inndia.pdf
Pharma ospi slides which help in ospi learning
Institutional Correction lecture only . . .
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Complications of Minimal Access Surgery at WLH
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Module 4: Burden of Disease Tutorial Slides S2 2025
Abdominal Access Techniques with Prof. Dr. R K Mishra
VCE English Exam - Section C Student Revision Booklet
Final Presentation General Medicine 03-08-2024.pptx
Classroom Observation Tools for Teachers
PPH.pptx obstetrics and gynecology in nursing
Computing-Curriculum for Schools in Ghana
Supply Chain Operations Speaking Notes -ICLT Program
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Ad

l01-intro (3).ppt

  • 1. The Design and Analysis of Algorithms by Anany Levitin Lecture notes prepared by Lydia Sinapova, Simpson College
  • 2. 2 CHAPTER 1: INTRODUCTION  What is an Algorithm  Steps in Designing and Implementing an Algorithm  Important Problem Types  Fundamental Data Structures
  • 3. 3 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
  • 4. 4 Important points  Non-ambiguity  Range of inputs  The same algorithm can be represented in different ways  Several algorithms for solving the same problem
  • 5. 5 gcd(m,n) while n ≠0 do r ← m mod n m ← n 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
  • 6. 6 Understand the problem Decide on computational means Exact vs approximate solution Data structures Algorithm design technique Design an algorithm Prove correctness Analyze the algorithm Code the algorithm
  • 7. 7 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?
  • 8. 8 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
  • 9. 9 Analyze the algorithm 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?
  • 10. 10 Important problem types  Sorting  Searching  String processing  Graph problems  Combinatorial problems  Geometric problems  Numerical problems
  • 11. 11 Fundamental data structures Linear data structures  Array  Linked list  Stack  Queue Operations: search, delete, insert Implementation: static, dynamic
  • 12. 12 Non-linear data structures  Graphs  Trees : connected graph without cycles Rooted trees  Ordered trees Binary trees Graph representation: adjacency lists, adjacency matrix Tree representation: as graphs; binary nodes Fundamental data structures
  • 13. 13 Fundamental data structures Sets, Bags, Dictionaries  Set: unordered collection of distinct elements Operations: membership, union, intersection Representation: bit string; linear structure  Bag: unordered collection, elements may be repeated  Dictionary: a bag with operations search, add, delete
  • 14. 14 Conclusion  Algorithm classification By types of problems By design technique  Design techniques a general approach to solving problems