SlideShare a Scribd company logo
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
Ad

More Related Content

What's hot (20)

Algorithms and Flowcharts
Algorithms and FlowchartsAlgorithms and Flowcharts
Algorithms and Flowcharts
Deva Singh
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
Elizabeth de Leon Aler
 
Types of software
Types of softwareTypes of software
Types of software
latifah2001
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and Algorithm
Dhaval Kaneria
 
Presentation on Programming Languages.
Presentation on Programming Languages.Presentation on Programming Languages.
Presentation on Programming Languages.
Mohammad Shakirul islam
 
Types of Operating System
Types of Operating SystemTypes of Operating System
Types of Operating System
Hemant Raj
 
High level and Low level Language
High level and Low level Language High level and Low level Language
High level and Low level Language
adnan usmani
 
Computer Software & its Types
Computer Software & its Types Computer Software & its Types
Computer Software & its Types
Muhammad Hammad Waseem
 
Data types
Data typesData types
Data types
Zahid Hussain
 
structured programming
structured programmingstructured programming
structured programming
Ahmad54321
 
Introduction to Operating Systems
Introduction to Operating SystemsIntroduction to Operating Systems
Introduction to Operating Systems
Mukesh Chinta
 
Looping statement in python
Looping statement in pythonLooping statement in python
Looping statement in python
RaginiJain21
 
Abstract Data Types
Abstract Data TypesAbstract Data Types
Abstract Data Types
karthikeyanC40
 
Quick sort-Data Structure
Quick sort-Data StructureQuick sort-Data Structure
Quick sort-Data Structure
Jeanie Arnoco
 
Algorithms and flowcharts
Algorithms and flowchartsAlgorithms and flowcharts
Algorithms and flowcharts
Samuel Igbanogu
 
Presentation on Operating System & its Components
Presentation on Operating System & its ComponentsPresentation on Operating System & its Components
Presentation on Operating System & its Components
Mahmuda Rahman
 
Programming for Problem Solving
Programming for Problem SolvingProgramming for Problem Solving
Programming for Problem Solving
Sukhendra Singh
 
Algorithm and Flowcharts
Algorithm and FlowchartsAlgorithm and Flowcharts
Algorithm and Flowcharts
Dr. SURBHI SAROHA
 
Computer architecture
Computer architectureComputer architecture
Computer architecture
Burhan Ahmed
 
Operating system presentation
Operating system presentationOperating system presentation
Operating system presentation
ashanrajpar
 
Algorithms and Flowcharts
Algorithms and FlowchartsAlgorithms and Flowcharts
Algorithms and Flowcharts
Deva Singh
 
Types of software
Types of softwareTypes of software
Types of software
latifah2001
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and Algorithm
Dhaval Kaneria
 
Types of Operating System
Types of Operating SystemTypes of Operating System
Types of Operating System
Hemant Raj
 
High level and Low level Language
High level and Low level Language High level and Low level Language
High level and Low level Language
adnan usmani
 
structured programming
structured programmingstructured programming
structured programming
Ahmad54321
 
Introduction to Operating Systems
Introduction to Operating SystemsIntroduction to Operating Systems
Introduction to Operating Systems
Mukesh Chinta
 
Looping statement in python
Looping statement in pythonLooping statement in python
Looping statement in python
RaginiJain21
 
Quick sort-Data Structure
Quick sort-Data StructureQuick sort-Data Structure
Quick sort-Data Structure
Jeanie Arnoco
 
Algorithms and flowcharts
Algorithms and flowchartsAlgorithms and flowcharts
Algorithms and flowcharts
Samuel Igbanogu
 
Presentation on Operating System & its Components
Presentation on Operating System & its ComponentsPresentation on Operating System & its Components
Presentation on Operating System & its Components
Mahmuda Rahman
 
Programming for Problem Solving
Programming for Problem SolvingProgramming for Problem Solving
Programming for Problem Solving
Sukhendra Singh
 
Computer architecture
Computer architectureComputer architecture
Computer architecture
Burhan Ahmed
 
Operating system presentation
Operating system presentationOperating system presentation
Operating system presentation
ashanrajpar
 

Similar to Algorithm (20)

Unit 1-problem solving with algorithm
Unit 1-problem solving with algorithmUnit 1-problem solving with algorithm
Unit 1-problem solving with algorithm
rajkumar1631010038
 
Algorithm defination, design & Implementation
Algorithm defination, design & ImplementationAlgorithm defination, design & Implementation
Algorithm defination, design & Implementation
Bilal Maqbool ツ
 
GE8151 notes pdf.pdf
GE8151 notes pdf.pdfGE8151 notes pdf.pdf
GE8151 notes pdf.pdf
payalkarmarkar1
 
Lesson 3
Lesson 3Lesson 3
Lesson 3
Dr. Rupinder Singh
 
11 Unit 1 Problem Solving Techniques
11  Unit 1 Problem Solving Techniques11  Unit 1 Problem Solving Techniques
11 Unit 1 Problem Solving Techniques
Praveen M Jigajinni
 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
ShaswatSurya
 
Basics of Algorithm Unit 1 part 1 algorithm
Basics of Algorithm Unit 1 part 1  algorithmBasics of Algorithm Unit 1 part 1  algorithm
Basics of Algorithm Unit 1 part 1 algorithm
JIMS LAJPAT NAGAR
 
Algorithms notes 2 tutorials duniya
Algorithms notes 2   tutorials duniyaAlgorithms notes 2   tutorials duniya
Algorithms notes 2 tutorials duniya
TutorialsDuniya.com
 
Chapter 6 algorithms and flow charts
Chapter 6  algorithms and flow chartsChapter 6  algorithms and flow charts
Chapter 6 algorithms and flow charts
Praveen M Jigajinni
 
Design and Analysis of Algorithm ppt for unit one
Design and Analysis of Algorithm ppt for unit oneDesign and Analysis of Algorithm ppt for unit one
Design and Analysis of Algorithm ppt for unit one
ssuserb7c8b8
 
01 Introduction to analysis of Algorithms.pptx
01 Introduction to analysis of Algorithms.pptx01 Introduction to analysis of Algorithms.pptx
01 Introduction to analysis of Algorithms.pptx
ssuser586772
 
DAA Unit 1.pdf
DAA Unit 1.pdfDAA Unit 1.pdf
DAA Unit 1.pdf
Nirmalavenkatachalam
 
"A short and knowledgeable concept about Algorithm "
"A short and knowledgeable concept about Algorithm ""A short and knowledgeable concept about Algorithm "
"A short and knowledgeable concept about Algorithm "
CHANDAN KUMAR
 
Unit 1(1).pptx Program Logic Development
Unit 1(1).pptx Program Logic DevelopmentUnit 1(1).pptx Program Logic Development
Unit 1(1).pptx Program Logic Development
Vaibhav Parjane
 
Lect 3-4 Zaheer Abbas
Lect 3-4 Zaheer AbbasLect 3-4 Zaheer Abbas
Lect 3-4 Zaheer Abbas
Information Technology Center
 
Algorithm in data structure bca .pptx
Algorithm  in  data  structure bca .pptxAlgorithm  in  data  structure bca .pptx
Algorithm in data structure bca .pptx
SukhBanger
 
What is algorithm
What is algorithmWhat is algorithm
What is algorithm
lilyMalar1
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
Sachin Goyani
 
DAA INTRO.pdf of design analysis algorithms
DAA INTRO.pdf of design analysis algorithmsDAA INTRO.pdf of design analysis algorithms
DAA INTRO.pdf of design analysis algorithms
VaishnaviDappu
 
Algorithmics, intro to data structures.pptx
Algorithmics,  intro to data structures.pptxAlgorithmics,  intro to data structures.pptx
Algorithmics, intro to data structures.pptx
OntopScenes
 
Unit 1-problem solving with algorithm
Unit 1-problem solving with algorithmUnit 1-problem solving with algorithm
Unit 1-problem solving with algorithm
rajkumar1631010038
 
Algorithm defination, design & Implementation
Algorithm defination, design & ImplementationAlgorithm defination, design & Implementation
Algorithm defination, design & Implementation
Bilal Maqbool ツ
 
11 Unit 1 Problem Solving Techniques
11  Unit 1 Problem Solving Techniques11  Unit 1 Problem Solving Techniques
11 Unit 1 Problem Solving Techniques
Praveen M Jigajinni
 
Basics of Algorithm Unit 1 part 1 algorithm
Basics of Algorithm Unit 1 part 1  algorithmBasics of Algorithm Unit 1 part 1  algorithm
Basics of Algorithm Unit 1 part 1 algorithm
JIMS LAJPAT NAGAR
 
Algorithms notes 2 tutorials duniya
Algorithms notes 2   tutorials duniyaAlgorithms notes 2   tutorials duniya
Algorithms notes 2 tutorials duniya
TutorialsDuniya.com
 
Chapter 6 algorithms and flow charts
Chapter 6  algorithms and flow chartsChapter 6  algorithms and flow charts
Chapter 6 algorithms and flow charts
Praveen M Jigajinni
 
Design and Analysis of Algorithm ppt for unit one
Design and Analysis of Algorithm ppt for unit oneDesign and Analysis of Algorithm ppt for unit one
Design and Analysis of Algorithm ppt for unit one
ssuserb7c8b8
 
01 Introduction to analysis of Algorithms.pptx
01 Introduction to analysis of Algorithms.pptx01 Introduction to analysis of Algorithms.pptx
01 Introduction to analysis of Algorithms.pptx
ssuser586772
 
"A short and knowledgeable concept about Algorithm "
"A short and knowledgeable concept about Algorithm ""A short and knowledgeable concept about Algorithm "
"A short and knowledgeable concept about Algorithm "
CHANDAN KUMAR
 
Unit 1(1).pptx Program Logic Development
Unit 1(1).pptx Program Logic DevelopmentUnit 1(1).pptx Program Logic Development
Unit 1(1).pptx Program Logic Development
Vaibhav Parjane
 
Algorithm in data structure bca .pptx
Algorithm  in  data  structure bca .pptxAlgorithm  in  data  structure bca .pptx
Algorithm in data structure bca .pptx
SukhBanger
 
What is algorithm
What is algorithmWhat is algorithm
What is algorithm
lilyMalar1
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
Sachin Goyani
 
DAA INTRO.pdf of design analysis algorithms
DAA INTRO.pdf of design analysis algorithmsDAA INTRO.pdf of design analysis algorithms
DAA INTRO.pdf of design analysis algorithms
VaishnaviDappu
 
Algorithmics, intro to data structures.pptx
Algorithmics,  intro to data structures.pptxAlgorithmics,  intro to data structures.pptx
Algorithmics, intro to data structures.pptx
OntopScenes
 
Ad

Recently uploaded (20)

Final Evaluation.docx...........................
Final Evaluation.docx...........................Final Evaluation.docx...........................
Final Evaluation.docx...........................
l1bbyburrell
 
Cultivation Practice of Turmeric in Nepal.pptx
Cultivation Practice of Turmeric in Nepal.pptxCultivation Practice of Turmeric in Nepal.pptx
Cultivation Practice of Turmeric in Nepal.pptx
UmeshTimilsina1
 
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales moduleHow To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
Celine George
 
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFAMEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
Dr. Nasir Mustafa
 
Myopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduateMyopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduate
Mohamed Rizk Khodair
 
Module 1: Foundations of Research
Module 1: Foundations of ResearchModule 1: Foundations of Research
Module 1: Foundations of Research
drroxannekemp
 
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 
*"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"**"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"*
Arshad Shaikh
 
Overview Well-Being and Creative Careers
Overview Well-Being and Creative CareersOverview Well-Being and Creative Careers
Overview Well-Being and Creative Careers
University of Amsterdam
 
Ajanta Paintings: Study as a Source of History
Ajanta Paintings: Study as a Source of HistoryAjanta Paintings: Study as a Source of History
Ajanta Paintings: Study as a Source of History
Virag Sontakke
 
What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)
jemille6
 
Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
Search Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo SlidesSearch Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo Slides
Celine George
 
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Leonel Morgado
 
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Association for Project Management
 
spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)
Mohamed Rizk Khodair
 
antiquity of writing in ancient India- literary & archaeological evidence
antiquity of writing in ancient India- literary & archaeological evidenceantiquity of writing in ancient India- literary & archaeological evidence
antiquity of writing in ancient India- literary & archaeological evidence
PrachiSontakke5
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living WorkshopLDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDM Mia eStudios
 
Final Evaluation.docx...........................
Final Evaluation.docx...........................Final Evaluation.docx...........................
Final Evaluation.docx...........................
l1bbyburrell
 
Cultivation Practice of Turmeric in Nepal.pptx
Cultivation Practice of Turmeric in Nepal.pptxCultivation Practice of Turmeric in Nepal.pptx
Cultivation Practice of Turmeric in Nepal.pptx
UmeshTimilsina1
 
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales moduleHow To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
Celine George
 
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFAMEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
Dr. Nasir Mustafa
 
Myopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduateMyopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduate
Mohamed Rizk Khodair
 
Module 1: Foundations of Research
Module 1: Foundations of ResearchModule 1: Foundations of Research
Module 1: Foundations of Research
drroxannekemp
 
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 
*"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"**"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"*
Arshad Shaikh
 
Overview Well-Being and Creative Careers
Overview Well-Being and Creative CareersOverview Well-Being and Creative Careers
Overview Well-Being and Creative Careers
University of Amsterdam
 
Ajanta Paintings: Study as a Source of History
Ajanta Paintings: Study as a Source of HistoryAjanta Paintings: Study as a Source of History
Ajanta Paintings: Study as a Source of History
Virag Sontakke
 
What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)
jemille6
 
Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
Search Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo SlidesSearch Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo Slides
Celine George
 
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Leonel Morgado
 
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Association for Project Management
 
spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)
Mohamed Rizk Khodair
 
antiquity of writing in ancient India- literary & archaeological evidence
antiquity of writing in ancient India- literary & archaeological evidenceantiquity of writing in ancient India- literary & archaeological evidence
antiquity of writing in ancient India- literary & archaeological evidence
PrachiSontakke5
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living WorkshopLDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDM Mia eStudios
 
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.
  翻译: