SlideShare a Scribd company logo
Introduction to Algorithms
Algorithm
Analysis
&
Design March 2020
1
S. Hassan Adelyar, Ph.D
Instructor of Computer Science Faculty
Kabul University
December 2020
Lesson I: Algorithm Analysis & Design
Introduction to Algorithms
Algorithm
Analysis
&
Design March 2020
2
Course Information
 Course Name: Algorithm Analysis & Design
 Course Code: SE0601
 Credit hours: 4
 Reference: Jeffrey J. McConnell (2001). Analysis of
Algorithms: An Active Learning Approach. Jones and
Bartlett Publishers, Canada.
 Pre-requisites: Programming Fundamentals, Data
Structures and Discreet Mathematics.
 The contents of the course is divided into 16 lessons.
 Each lesson include presentation, video, quiz, &
discussion.
p
Introduction to Algorithms
Algorithm
Analysis
&
Design March 2020
3
Learning Outcome
 By the end of this presentation, students will
be able to:
 Understand Algorithms
 Understand the design of Algorithms
 Understand flow chart & Pseudocode
 Understand the properties of Algorithms
 Understand the importance of Algorithms
 Recognize the types of Algorithms
p
Introduction to Algorithms
Algorithm
Analysis
&
Design March 2020
4
Algorithm
 Series of Steps for solving a problem
 Set of instructions
 Transfer input to output
 Solve a specific task
p
Introduction to Algorithms
Algorithm
Analysis
&
Design March 2020
5
Implementing Algorithms
p
Introduction to Algorithms
Algorithm
Analysis
&
Design March 2020
6
 Example
 Sorting
 Searching
 Find Minimum
 Find Maximum
 Find shortest path between two points
 Etc.
p
Introduction to Algorithms
Algorithm
Analysis
&
Design March 2020
7
 Algorithms can be expressed in many ways:
 Flow charts
 Pseudo-code
p
Introduction to Algorithms
Algorithm
Analysis
&
Design March 2020
8
Flow Chart Example
p
Introduction to Algorithms
Algorithm
Analysis
&
Design March 2020
9
Pseudo-code
p
x = 0
while (x < 25)
print x
end
Introduction to Algorithms
Algorithm
Analysis
&
Design March 2020
10
Properties of Algorithm
 Finiteness
 Definiteness
 Input
 Output
 Effectiveness
p
Introduction to Algorithms
Algorithm
Analysis
&
Design March 2020
11
Importance of Algorithm
 Algorithm as a Technology
 Processing of a large amount of data.
 Execution time is very important when
processing a large amount of input.
 Algorithms solve the same problem in
different time.
 Differences can be much more than
hardware.
p
Introduction to Algorithms
Algorithm
Analysis
&
Design March 2020
12
 Efficiency:
 Suppose computers were infinitely fast. Would you
have any reason to study algorithm?
 Good software engineering practice.
 Select the easiest implementation.
 New application demand increase in speed.
 Time is a non-linear function of the input size.
 This can reduce their ability to benefit from the
increase in speed when the input size is large.
p
Introduction to Algorithms
Algorithm
Analysis
&
Design March 2020
13
Examples
 Linear Search & Binary Search
 Insertion Sort, Merge Sort & Quick Sort
 Fibonacci by recursion, iteration, dynamic
approach
p
Introduction to Algorithms
Algorithm
Analysis
&
Design March 2020
14
 The execution time of many complex
algorithms can vary due to factors other than
the size of the input.
 For example, sorting items that are already
sorted.
p
Introduction to Algorithms
Algorithm
Analysis
&
Design March 2020
15
Factors that Affect Speed
 Problem being solved
 Programming language
 Compiler
 Computer hardware
 Programmer ability
 Algorithm
p
Introduction to Algorithms
Algorithm
Analysis
&
Design March 2020
16
Types of algorithms
 Recursive Algorithms
 Backtracking Algorithms
 Divide-and-conquer Algorithms
 Dynamic Programming Algorithms
 Greedy Algorithms
 Brute Force Algorithms
p
Introduction to Algorithms
Algorithm
Analysis
&
Design March 2020
17 Summary
 In this presentation, we studied Algorithms &
Algorithm design techniques.
 The presentation of Algorithm with the flowchart
& pseudocode was explained with examples.
 In addition to Algorithm, the properties of
Algorithms, importance of Algorithms & types
of Algorithms were explained
p
Introduction to Algorithms
Algorithm
Analysis
&
Design March 2020
18
Exercises
 Write an algorithm in pseudo-code to count the
number of capital letters in a file of text. How
many comparisons does it do? What is the fewest
number of increments it might do? What is the
largest number?
 There is a set of numbers stored in a file, but we
don’t know how many it contains. Write an
algorithm in pseudo-code to calculate the average
of the numbers stored in this file. What type of
operations does your algorithm do? How many of
each of these operations does your algorithm do?
p
Introduction to Algorithms
Algorithm
Analysis
&
Design March 2020
19
 Write an algorithm to find the second largest
element in a list of N values. How many
comparisons does your algorithm do in the worst
case?
 1- Write an algorithm and draw a flowchart to
convert the length in feet to centimeter.
 2- Write an algorithm and draw a flowchart that will
read the two sides of a rectangle and calculate its
area.
p
End of Lesson 1
Question?

More Related Content

PPTX
Lecture 1.pptx
PPTX
Design and Analysis of Algorithm ppt for unit one
PPTX
Introduction-to-Algorithms-Concepts-and-Analysis.pptx
PPTX
Algo_lecture1-3.pptx
PDF
1. Introduction to Algorithms, Specification of Algorithm, Complexity.pdf
PPTX
Lesson num 2 - Algorithm Analysis - I.pptx
PDF
Algorithms Lecture 1: Introduction to Algorithms
PPT
Lec1.ppt
Lecture 1.pptx
Design and Analysis of Algorithm ppt for unit one
Introduction-to-Algorithms-Concepts-and-Analysis.pptx
Algo_lecture1-3.pptx
1. Introduction to Algorithms, Specification of Algorithm, Complexity.pdf
Lesson num 2 - Algorithm Analysis - I.pptx
Algorithms Lecture 1: Introduction to Algorithms
Lec1.ppt

Similar to Lesson 1 - Introduction to Algorithms.pptx (20)

PPSX
Ds03 part i algorithms by jyoti lakhani
PDF
01 Revision Introduction SLides Od Design ANd Aalaysis Of aLgo
PDF
Lecture 2 role of algorithms in computing
PDF
Algorithm Analysis.pdf
PDF
Algorithms notes 2 tutorials duniya
PPTX
Algorithm in data structure bca .pptx
PDF
Introduction to analysis algorithm in computer Science
PDF
introduction to analysis of algorithm in computer science
PPTX
Algorithm analysis (All in one)
PDF
Chapter-1-Introduction-to-Aglorithms.pdf
PPSX
Data Structure and Algorithm Chapter 1.ppsx
PPTX
Modile-1-PPT-1-BCAC0207-AlgorithmDesign.pptx
PDF
Algorithms.pdf
PPT
introegthnhhdfhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhppt
PPTX
Binary to hexadecimal algorithmic old.pptx
PDF
Introduction to Algorithms Complexity Analysis
PPT
chapter 1
PPTX
Design and analysis of algorithm lec 1.pptx
PPTX
DAA Lecture on the accountabiltity of DAA
PDF
Design and analysis of algorithms
Ds03 part i algorithms by jyoti lakhani
01 Revision Introduction SLides Od Design ANd Aalaysis Of aLgo
Lecture 2 role of algorithms in computing
Algorithm Analysis.pdf
Algorithms notes 2 tutorials duniya
Algorithm in data structure bca .pptx
Introduction to analysis algorithm in computer Science
introduction to analysis of algorithm in computer science
Algorithm analysis (All in one)
Chapter-1-Introduction-to-Aglorithms.pdf
Data Structure and Algorithm Chapter 1.ppsx
Modile-1-PPT-1-BCAC0207-AlgorithmDesign.pptx
Algorithms.pdf
introegthnhhdfhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhppt
Binary to hexadecimal algorithmic old.pptx
Introduction to Algorithms Complexity Analysis
chapter 1
Design and analysis of algorithm lec 1.pptx
DAA Lecture on the accountabiltity of DAA
Design and analysis of algorithms
Ad

Recently uploaded (20)

PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Insiders guide to clinical Medicine.pdf
PDF
Basic Mud Logging Guide for educational purpose
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
RMMM.pdf make it easy to upload and study
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
master seminar digital applications in india
PDF
Pre independence Education in Inndia.pdf
PDF
Sports Quiz easy sports quiz sports quiz
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Classroom Observation Tools for Teachers
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Computing-Curriculum for Schools in Ghana
PPTX
GDM (1) (1).pptx small presentation for students
Supply Chain Operations Speaking Notes -ICLT Program
Insiders guide to clinical Medicine.pdf
Basic Mud Logging Guide for educational purpose
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPH.pptx obstetrics and gynecology in nursing
Anesthesia in Laparoscopic Surgery in India
RMMM.pdf make it easy to upload and study
Microbial disease of the cardiovascular and lymphatic systems
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
master seminar digital applications in india
Pre independence Education in Inndia.pdf
Sports Quiz easy sports quiz sports quiz
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Classroom Observation Tools for Teachers
Pharmacology of Heart Failure /Pharmacotherapy of CHF
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Computing-Curriculum for Schools in Ghana
GDM (1) (1).pptx small presentation for students
Ad

Lesson 1 - Introduction to Algorithms.pptx

  • 1. Introduction to Algorithms Algorithm Analysis & Design March 2020 1 S. Hassan Adelyar, Ph.D Instructor of Computer Science Faculty Kabul University December 2020 Lesson I: Algorithm Analysis & Design
  • 2. Introduction to Algorithms Algorithm Analysis & Design March 2020 2 Course Information  Course Name: Algorithm Analysis & Design  Course Code: SE0601  Credit hours: 4  Reference: Jeffrey J. McConnell (2001). Analysis of Algorithms: An Active Learning Approach. Jones and Bartlett Publishers, Canada.  Pre-requisites: Programming Fundamentals, Data Structures and Discreet Mathematics.  The contents of the course is divided into 16 lessons.  Each lesson include presentation, video, quiz, & discussion. p
  • 3. Introduction to Algorithms Algorithm Analysis & Design March 2020 3 Learning Outcome  By the end of this presentation, students will be able to:  Understand Algorithms  Understand the design of Algorithms  Understand flow chart & Pseudocode  Understand the properties of Algorithms  Understand the importance of Algorithms  Recognize the types of Algorithms p
  • 4. Introduction to Algorithms Algorithm Analysis & Design March 2020 4 Algorithm  Series of Steps for solving a problem  Set of instructions  Transfer input to output  Solve a specific task p
  • 5. Introduction to Algorithms Algorithm Analysis & Design March 2020 5 Implementing Algorithms p
  • 6. Introduction to Algorithms Algorithm Analysis & Design March 2020 6  Example  Sorting  Searching  Find Minimum  Find Maximum  Find shortest path between two points  Etc. p
  • 7. Introduction to Algorithms Algorithm Analysis & Design March 2020 7  Algorithms can be expressed in many ways:  Flow charts  Pseudo-code p
  • 8. Introduction to Algorithms Algorithm Analysis & Design March 2020 8 Flow Chart Example p
  • 9. Introduction to Algorithms Algorithm Analysis & Design March 2020 9 Pseudo-code p x = 0 while (x < 25) print x end
  • 10. Introduction to Algorithms Algorithm Analysis & Design March 2020 10 Properties of Algorithm  Finiteness  Definiteness  Input  Output  Effectiveness p
  • 11. Introduction to Algorithms Algorithm Analysis & Design March 2020 11 Importance of Algorithm  Algorithm as a Technology  Processing of a large amount of data.  Execution time is very important when processing a large amount of input.  Algorithms solve the same problem in different time.  Differences can be much more than hardware. p
  • 12. Introduction to Algorithms Algorithm Analysis & Design March 2020 12  Efficiency:  Suppose computers were infinitely fast. Would you have any reason to study algorithm?  Good software engineering practice.  Select the easiest implementation.  New application demand increase in speed.  Time is a non-linear function of the input size.  This can reduce their ability to benefit from the increase in speed when the input size is large. p
  • 13. Introduction to Algorithms Algorithm Analysis & Design March 2020 13 Examples  Linear Search & Binary Search  Insertion Sort, Merge Sort & Quick Sort  Fibonacci by recursion, iteration, dynamic approach p
  • 14. Introduction to Algorithms Algorithm Analysis & Design March 2020 14  The execution time of many complex algorithms can vary due to factors other than the size of the input.  For example, sorting items that are already sorted. p
  • 15. Introduction to Algorithms Algorithm Analysis & Design March 2020 15 Factors that Affect Speed  Problem being solved  Programming language  Compiler  Computer hardware  Programmer ability  Algorithm p
  • 16. Introduction to Algorithms Algorithm Analysis & Design March 2020 16 Types of algorithms  Recursive Algorithms  Backtracking Algorithms  Divide-and-conquer Algorithms  Dynamic Programming Algorithms  Greedy Algorithms  Brute Force Algorithms p
  • 17. Introduction to Algorithms Algorithm Analysis & Design March 2020 17 Summary  In this presentation, we studied Algorithms & Algorithm design techniques.  The presentation of Algorithm with the flowchart & pseudocode was explained with examples.  In addition to Algorithm, the properties of Algorithms, importance of Algorithms & types of Algorithms were explained p
  • 18. Introduction to Algorithms Algorithm Analysis & Design March 2020 18 Exercises  Write an algorithm in pseudo-code to count the number of capital letters in a file of text. How many comparisons does it do? What is the fewest number of increments it might do? What is the largest number?  There is a set of numbers stored in a file, but we don’t know how many it contains. Write an algorithm in pseudo-code to calculate the average of the numbers stored in this file. What type of operations does your algorithm do? How many of each of these operations does your algorithm do? p
  • 19. Introduction to Algorithms Algorithm Analysis & Design March 2020 19  Write an algorithm to find the second largest element in a list of N values. How many comparisons does your algorithm do in the worst case?  1- Write an algorithm and draw a flowchart to convert the length in feet to centimeter.  2- Write an algorithm and draw a flowchart that will read the two sides of a rectangle and calculate its area. p
  • 20. End of Lesson 1 Question?