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

What's hot (20)

PPTX
Algorithm Introduction
Ashim Lamichhane
 
PPTX
Bruteforce algorithm
Rezwan Siam
 
PPT
Introduction to data structures and Algorithm
Dhaval Kaneria
 
PDF
Algorithms Lecture 1: Introduction to Algorithms
Mohamed Loey
 
PPT
Algorithm Design Presentation
Kawsar Ahmed
 
PPTX
Operating system and its types
vimal kumar arora
 
PPTX
sorting and its types
SIVASHANKARIRAJAN
 
PPTX
Our presentation on algorithm design
Nahid Hasan
 
PPTX
Programming Fundamentals
Trivuz ত্রিভুজ
 
PPTX
Dijkstra's Algorithm
Rashik Ishrak Nahian
 
PPT
Binary Search
kunj desai
 
PPTX
Sorting
Ashim Lamichhane
 
PPT
Bubble sort
Manek Ar
 
PPTX
Process management os concept
priyadeosarkar91
 
PDF
Algorithmic problem solving
Prabhakaran V M
 
PPTX
Prim's algorithm
Pankaj Thakur
 
PPT
Array in c
Ravi Gelani
 
PPTX
STACKS IN DATASTRUCTURE
Archie Jamwal
 
PPTX
Queue ppt
SouravKumar328
 
PPTX
Sorting Algorithms
Pranay Neema
 
Algorithm Introduction
Ashim Lamichhane
 
Bruteforce algorithm
Rezwan Siam
 
Introduction to data structures and Algorithm
Dhaval Kaneria
 
Algorithms Lecture 1: Introduction to Algorithms
Mohamed Loey
 
Algorithm Design Presentation
Kawsar Ahmed
 
Operating system and its types
vimal kumar arora
 
sorting and its types
SIVASHANKARIRAJAN
 
Our presentation on algorithm design
Nahid Hasan
 
Programming Fundamentals
Trivuz ত্রিভুজ
 
Dijkstra's Algorithm
Rashik Ishrak Nahian
 
Binary Search
kunj desai
 
Bubble sort
Manek Ar
 
Process management os concept
priyadeosarkar91
 
Algorithmic problem solving
Prabhakaran V M
 
Prim's algorithm
Pankaj Thakur
 
Array in c
Ravi Gelani
 
STACKS IN DATASTRUCTURE
Archie Jamwal
 
Queue ppt
SouravKumar328
 
Sorting Algorithms
Pranay Neema
 

Similar to Algorithm (20)

PPTX
Algorithms maths.pptx
DrakshuDrakshi
 
DOCX
Algorithm - A set of rules for solving operations
Kumari99
 
PDF
DAA INTRO.pdf of design analysis algorithms
VaishnaviDappu
 
PPTX
Design and Analysis of Algorithm ppt for unit one
ssuserb7c8b8
 
PPTX
Algorithm in data structure bca .pptx
SukhBanger
 
PPTX
"A short and knowledgeable concept about Algorithm "
CHANDAN KUMAR
 
PDF
Algorithms notes 2 tutorials duniya
TutorialsDuniya.com
 
PDF
Basics of Algorithm Unit 1 part 1 algorithm
JIMS LAJPAT NAGAR
 
PPT
UNIT-1-PPTS-DAA.ppt
SamridhiGulati4
 
PPT
Introduction to Design Algorithm And Analysis.ppt
BhargaviDalal4
 
PPT
UNIT-1-PPTS-DAA.ppt
racha49
 
PPT
UNIT-1-PPTS-DAA INTRO WITH DIVIDE AND CONQUER
Salini P
 
PPT
UNIT 1- Design Analysis of algorithms and its working
Bobby Pra A
 
PPT
UNIT-1-PPTS-DAA_INTRODUCTION_TO_DAA_GH.ppt
sravansonga007
 
PDF
UNIT-1-PdjfjfjfjfjfjfjfjfjfjfjPTS-DAA.pdf
NagendraK18
 
PDF
UNIT-1-PPTS-DAA_cofjfjvjcjcncnfncmpressed.pdf
NagendraK18
 
PPTX
Binary to hexadecimal algorithmic old.pptx
bulbul931579
 
PPT
Lesson 3
Dr. Rupinder Singh
 
PPTX
Lec 2 -algorithms-flowchart-and-pseudocode1.pptx
AbdelrahmanRagab36
 
PPT
UNIT-1-PPT-DESIGN AND ANALYSIS OF ALGORITHMS
ramalakshmikaliappan
 
Algorithms maths.pptx
DrakshuDrakshi
 
Algorithm - A set of rules for solving operations
Kumari99
 
DAA INTRO.pdf of design analysis algorithms
VaishnaviDappu
 
Design and Analysis of Algorithm ppt for unit one
ssuserb7c8b8
 
Algorithm in data structure bca .pptx
SukhBanger
 
"A short and knowledgeable concept about Algorithm "
CHANDAN KUMAR
 
Algorithms notes 2 tutorials duniya
TutorialsDuniya.com
 
Basics of Algorithm Unit 1 part 1 algorithm
JIMS LAJPAT NAGAR
 
UNIT-1-PPTS-DAA.ppt
SamridhiGulati4
 
Introduction to Design Algorithm And Analysis.ppt
BhargaviDalal4
 
UNIT-1-PPTS-DAA.ppt
racha49
 
UNIT-1-PPTS-DAA INTRO WITH DIVIDE AND CONQUER
Salini P
 
UNIT 1- Design Analysis of algorithms and its working
Bobby Pra A
 
UNIT-1-PPTS-DAA_INTRODUCTION_TO_DAA_GH.ppt
sravansonga007
 
UNIT-1-PdjfjfjfjfjfjfjfjfjfjfjPTS-DAA.pdf
NagendraK18
 
UNIT-1-PPTS-DAA_cofjfjvjcjcncnfncmpressed.pdf
NagendraK18
 
Binary to hexadecimal algorithmic old.pptx
bulbul931579
 
Lec 2 -algorithms-flowchart-and-pseudocode1.pptx
AbdelrahmanRagab36
 
UNIT-1-PPT-DESIGN AND ANALYSIS OF ALGORITHMS
ramalakshmikaliappan
 
Ad

Recently uploaded (20)

PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PPTX
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
PDF
Geographical Diversity of India 100 Mcq.pdf/ 7th class new ncert /Social/Samy...
Sandeep Swamy
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PPTX
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PPTX
PPT-Q1-WEEK-3-SCIENCE-ERevised Matatag Grade 3.pptx
reijhongidayawan02
 
PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PDF
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
PPTX
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
PDF
Dimensions of Societal Planning in Commonism
StefanMz
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PDF
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
PDF
Horarios de distribución de agua en julio
pegazohn1978
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PPTX
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
PPTX
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
Geographical Diversity of India 100 Mcq.pdf/ 7th class new ncert /Social/Samy...
Sandeep Swamy
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PPT-Q1-WEEK-3-SCIENCE-ERevised Matatag Grade 3.pptx
reijhongidayawan02
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
Dimensions of Societal Planning in Commonism
StefanMz
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
Horarios de distribución de agua en julio
pegazohn1978
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
Ad

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.