SlideShare a Scribd company logo
3
Most read
5
Most read
7
Most read
Algorithm
Algorithm
o BY : IHTISHAM UL HAQ
What is Algorithm?
 An algorithm is a well-defined procedure that allows
a computer to solve a problem.
 An algorithm is a sequence of unambiguous
instructions. ...
Histroy of Algorithm
 An algorithm (pronounced AL-go-rith-um) is a
procedure or formula for solving a problem.
 The word derives from the name of the
mathematician , Mohammad Ibn-Musa-al-Khwarizmi,
who was part of the royal court in Baghdad and who
lived from about 780 to 850. Al Khwarizmi’s work is
the likely source for the word algebra as well.
How to write an algorithm?
 Keep in mind that algorithm is a step-by-step
process.
 Depending upon programming language, include
syntax where necessary.
 Include variables and their usage.
 If they are any loops, try to give sub number lists.
 Try to give go back to step number if loop or
condition fails.
 Use jump statement to jump from one statement
to another.
How to write an algorithm?
 Try to avoid unwanted raw data in algorithm.
 Use break and stop to terminate the process.
Characteristics of Algorithm
 The characteristics of a good algorithm are:
 Precision – the steps are precisely stated(defined).
 Uniqueness – results of each step are
uniquely defined and only depend on
the input and the result of the preceding steps.
 Finiteness – the algorithm stops after
a finite number of instructions are executed.
Properties of Algorithm
 An algorithm must have five properties:
 Input specified.
 Output specified.
 Definiteness.
 Effectiveness.
 Finiteness.
Types of Algorithm
 Algorithm types we will consider include:
 Simple recursive algorithms.
 Backtracking algorithms.
 Divide and conquer algorithms.
 Dynamic programming algorithms.
 Greedy algorithms.
 Branch and bound algorithms.
 Brute force algorithms.
 Randomized algorithms.
Example
 Algorithm in daily life.
 Algorithm for making a Brownies
 Ingredients:
 ½ cup butter or margarine.
 1 tea spoon vanilla extract .
 1 cup sugar.
 ½ cup cocoa.
 2 eggs .
 ½ cup flour.
Cont…
Example
 Procedure:
 1. If butter not soft, then melt butter .
 2. Blend melted butter and sugar until mixture has
creamy consistency.
 3. Add eggs and vanilla; stir .
 4. Add cocoa and flour; mix until well blended .
 5. Pour into greased round glass cake pan.
 6. Microwave for 8-9 minutes.
 7.Brownies are ready.
Example
 Algorithm in Programming.
 Write an algorithm to determine a student’s final grade and
indicate whether it is passing or failing. The final grade is
calculated as the average of four marks.
 Pseudocode:
 Input a set of 4 marks .
 Calculate their average by summing and dividing by 4.
 if average is below 50
 Print “FAIL”
 else
 Print “PASS”
Example
 Detailed Algorithm :
 Step 1: Input M1,M2,M3,M4 .
 Step 2: GRADE (M1+M2+M3+M4)/4 .
 Step 3: if (GRADE < 50)
 then
 Print “FAIL”
 else
 Print “PASS”
 End if
Example
 Pseudocode:
 Input the length in feet (Lft).
 Calculate the length in cm (Lcm) by multiplying LFT
with 30.
 Print length in cm (LCM).
Example
 Algorithm :
 Step 1: Input Lft.
 Step 2: Lcm Lft x 30.
 Step 3: Print Lcm.
Thanks

More Related Content

PPTX
What is an algorithm?
PDF
Data structure ppt
PPTX
Analysis and Design of Algorithms
PPTX
Our presentation on algorithm design
PPTX
Markov chain-model
PPTX
Algorithm Introduction
PPTX
ppt of flowchart
PPTX
Agents in Artificial intelligence
What is an algorithm?
Data structure ppt
Analysis and Design of Algorithms
Our presentation on algorithm design
Markov chain-model
Algorithm Introduction
ppt of flowchart
Agents in Artificial intelligence

What's hot (20)

PPT
Variables in C Programming
PDF
Operators in c programming
PPTX
Presentation on Function in C Programming
PPTX
Method overloading
PPS
Java Exception handling
PPSX
INTRODUCTION TO C PROGRAMMING
PPTX
Data types in python
PPTX
STACKS IN DATASTRUCTURE
PPTX
data types in C programming
PPTX
Operator.ppt
PPTX
Constant, variables, data types
PPTX
Arrays in c
PPT
structure and union
PPT
Constants in C Programming
PPTX
single linked list
PPTX
Introduction to flowchart
PPTX
Unit 3. Input and Output
PDF
Strings in python
PPTX
DeadLock in Operating-Systems
PPTX
Linked list
Variables in C Programming
Operators in c programming
Presentation on Function in C Programming
Method overloading
Java Exception handling
INTRODUCTION TO C PROGRAMMING
Data types in python
STACKS IN DATASTRUCTURE
data types in C programming
Operator.ppt
Constant, variables, data types
Arrays in c
structure and union
Constants in C Programming
single linked list
Introduction to flowchart
Unit 3. Input and Output
Strings in python
DeadLock in Operating-Systems
Linked list
Ad

Similar to Algorithm (20)

PDF
Unit 1-problem solving with algorithm
PPTX
Introduction to python Grade 10 with exercies.pptx
PDF
Algorithm defination, design & Implementation
PDF
GE8151 notes pdf.pdf
PPT
PPTX
11 Unit 1 Problem Solving Techniques
PPTX
UNIT 1.pptx
PDF
Basics of Algorithm Unit 1 part 1 algorithm
PDF
Algorithms notes 2 tutorials duniya
PPTX
Chapter 6 algorithms and flow charts
PPTX
Design and Analysis of Algorithm ppt for unit one
PPTX
01 Introduction to analysis of Algorithms.pptx
PDF
DAA Unit 1.pdf
PPTX
"A short and knowledgeable concept about Algorithm "
PPTX
Unit 1(1).pptx Program Logic Development
PDF
What is an Algorithm and Flow Chart along with step wise problem solvingt
PPT
Lect 3-4 Zaheer Abbas
PPTX
Algorithm in data structure bca .pptx
PPTX
What is algorithm
PPSX
Algorithm and flowchart
Unit 1-problem solving with algorithm
Introduction to python Grade 10 with exercies.pptx
Algorithm defination, design & Implementation
GE8151 notes pdf.pdf
11 Unit 1 Problem Solving Techniques
UNIT 1.pptx
Basics of Algorithm Unit 1 part 1 algorithm
Algorithms notes 2 tutorials duniya
Chapter 6 algorithms and flow charts
Design and Analysis of Algorithm ppt for unit one
01 Introduction to analysis of Algorithms.pptx
DAA Unit 1.pdf
"A short and knowledgeable concept about Algorithm "
Unit 1(1).pptx Program Logic Development
What is an Algorithm and Flow Chart along with step wise problem solvingt
Lect 3-4 Zaheer Abbas
Algorithm in data structure bca .pptx
What is algorithm
Algorithm and flowchart
Ad

Recently uploaded (20)

PDF
Types of Literary Text: Poetry and Prose
PPTX
Strengthening open access through collaboration: building connections with OP...
PPTX
Open Quiz Monsoon Mind Game Final Set.pptx
PDF
LDMMIA Reiki Yoga Workshop 15 MidTerm Review
PPTX
Open Quiz Monsoon Mind Game Prelims.pptx
PDF
What Is Coercive Control? Understanding and Recognizing Hidden Abuse
PPTX
ACUTE NASOPHARYNGITIS. pptx
PPTX
How to Manage Bill Control Policy in Odoo 18
PPTX
IMMUNIZATION PROGRAMME pptx
PPTX
Introduction and Scope of Bichemistry.pptx
PDF
High Ground Student Revision Booklet Preview
PPTX
Information Texts_Infographic on Forgetting Curve.pptx
PDF
Phylum Arthropoda: Characteristics and Classification, Entomology Lecture
PDF
Module 3: Health Systems Tutorial Slides S2 2025
PPTX
An introduction to Dialogue writing.pptx
PDF
Mga Unang Hakbang Tungo Sa Tao by Joe Vibar Nero.pdf
PPTX
vedic maths in python:unleasing ancient wisdom with modern code
PPTX
Congenital Hypothyroidism pptx
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PPTX
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
Types of Literary Text: Poetry and Prose
Strengthening open access through collaboration: building connections with OP...
Open Quiz Monsoon Mind Game Final Set.pptx
LDMMIA Reiki Yoga Workshop 15 MidTerm Review
Open Quiz Monsoon Mind Game Prelims.pptx
What Is Coercive Control? Understanding and Recognizing Hidden Abuse
ACUTE NASOPHARYNGITIS. pptx
How to Manage Bill Control Policy in Odoo 18
IMMUNIZATION PROGRAMME pptx
Introduction and Scope of Bichemistry.pptx
High Ground Student Revision Booklet Preview
Information Texts_Infographic on Forgetting Curve.pptx
Phylum Arthropoda: Characteristics and Classification, Entomology Lecture
Module 3: Health Systems Tutorial Slides S2 2025
An introduction to Dialogue writing.pptx
Mga Unang Hakbang Tungo Sa Tao by Joe Vibar Nero.pdf
vedic maths in python:unleasing ancient wisdom with modern code
Congenital Hypothyroidism pptx
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx

Algorithm

  • 2. Algorithm o BY : IHTISHAM UL HAQ
  • 3. What is Algorithm?  An algorithm is a well-defined procedure that allows a computer to solve a problem.  An algorithm is a sequence of unambiguous instructions. ...
  • 4. Histroy of Algorithm  An algorithm (pronounced AL-go-rith-um) is a procedure or formula for solving a problem.  The word derives from the name of the mathematician , Mohammad Ibn-Musa-al-Khwarizmi, who was part of the royal court in Baghdad and who lived from about 780 to 850. Al Khwarizmi’s work is the likely source for the word algebra as well.
  • 5. How to write an algorithm?  Keep in mind that algorithm is a step-by-step process.  Depending upon programming language, include syntax where necessary.  Include variables and their usage.  If they are any loops, try to give sub number lists.  Try to give go back to step number if loop or condition fails.  Use jump statement to jump from one statement to another.
  • 6. How to write an algorithm?  Try to avoid unwanted raw data in algorithm.  Use break and stop to terminate the process.
  • 7. Characteristics of Algorithm  The characteristics of a good algorithm are:  Precision – the steps are precisely stated(defined).  Uniqueness – results of each step are uniquely defined and only depend on the input and the result of the preceding steps.  Finiteness – the algorithm stops after a finite number of instructions are executed.
  • 8. Properties of Algorithm  An algorithm must have five properties:  Input specified.  Output specified.  Definiteness.  Effectiveness.  Finiteness.
  • 9. Types of Algorithm  Algorithm types we will consider include:  Simple recursive algorithms.  Backtracking algorithms.  Divide and conquer algorithms.  Dynamic programming algorithms.  Greedy algorithms.  Branch and bound algorithms.  Brute force algorithms.  Randomized algorithms.
  • 10. Example  Algorithm in daily life.  Algorithm for making a Brownies  Ingredients:  ½ cup butter or margarine.  1 tea spoon vanilla extract .  1 cup sugar.  ½ cup cocoa.  2 eggs .  ½ cup flour. Cont…
  • 11. Example  Procedure:  1. If butter not soft, then melt butter .  2. Blend melted butter and sugar until mixture has creamy consistency.  3. Add eggs and vanilla; stir .  4. Add cocoa and flour; mix until well blended .  5. Pour into greased round glass cake pan.  6. Microwave for 8-9 minutes.  7.Brownies are ready.
  • 12. Example  Algorithm in Programming.  Write an algorithm to determine a student’s final grade and indicate whether it is passing or failing. The final grade is calculated as the average of four marks.  Pseudocode:  Input a set of 4 marks .  Calculate their average by summing and dividing by 4.  if average is below 50  Print “FAIL”  else  Print “PASS”
  • 13. Example  Detailed Algorithm :  Step 1: Input M1,M2,M3,M4 .  Step 2: GRADE (M1+M2+M3+M4)/4 .  Step 3: if (GRADE < 50)  then  Print “FAIL”  else  Print “PASS”  End if
  • 14. Example  Pseudocode:  Input the length in feet (Lft).  Calculate the length in cm (Lcm) by multiplying LFT with 30.  Print length in cm (LCM).
  • 15. Example  Algorithm :  Step 1: Input Lft.  Step 2: Lcm Lft x 30.  Step 3: Print Lcm.