SlideShare a Scribd company logo
2
Most read
3
Most read
6
Most read
WHAT IS AN ALGORITHM?
It is a set of instructions of how to carry out a process. An algorithm lists the steps that must
be followed to complete the process and to reach the solution
Examples:
• A knitting pattern
• A set of instructions telling you how to put a kit together (eg. an kitchen unit)
• A recipe in a cook book
• An algorithm can be represented diagrammatically in the form of a flow chart.
Algorithm constructions:
There are three different constructions of algorithms.
Properties of Algorithms:
• An algorithm is an exact specification of how to solve a computational problem
• An algorithm must specify every step completely, so a computer can implement it
without any further “understanding”
• An algorithm must work for all possible inputs of the problem.
• Algorithms must be:
 Correct: For each input produce an appropriate output
 Efficient: run as quickly as possible, and use as little memory as possible – more
about this later
• There can be many different algorithms for each computational problem.
Algorithms Phases:
A typical programming task can be divided into two phases:
1. Problem solving phase (Designing)
• produce an ordered sequence of steps that describe solution of problem
• this sequence of steps is called an algorithm
2. Implementation phase
• implement the program in some programming language
Problem solving phase (Designing) :
Steps in Problem Solving
• First produce a general algorithm (one can use pseudocode)
• Refine the algorithm successively to get step by step detailed algorithm that is
very close to a computer language.
• Pseudocode is an artificial and informal language that helps programmers
develop algorithms. Pseudocode is very similar to everyday English.
Pseudocode Example:
Example 1: 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”
The Flowchart:
• (Dictionary) A schematic representation of a sequence of operations, as in a
manufacturing process or computer program.
• (Technical) A graphical representation of the sequence of operations in an
information system or program. Information system flowcharts show how data flows
from source documents through the computer to final distribution to users. Program
flowcharts show the sequence of instructions in a single program or subroutine.
Different symbols are used to draw each type of flowchart.
• shows logic of an algorithm
• emphasizes individual steps and their interconnections
• e.g. control flow from one action to the next
Flowchart Symbols:
• A flowchart consists of a sequence of instructions linked together by arrows to show
the order in which the instructions must be carried out.
• It provides detailed steps.
• Each instruction is put into a box. The boxes are different shapes depending upon
what the instruction is.
Oval
Parallelogram
Rectangle
Diamond
Hybrid
Name Symbol Use in Flowchart
Denotes the beginning or end of the program
Denotes an input operation
Denotes an output operation
Denotes a decision (or branch) to be made.
The program should continue along one of
two routes. (e.g. IF/THEN/ELSE)
Denotes a process to be carried out
e.g. addition, subtraction, division etc.
Flow line Denotes the direction of logic flow in the program
Example 1:
MAKING A CUP OF TEA!
Pseudocode:
1. Take tea bag out of cup
2. Boil the water
3. Put tea bag in cup
4. Add milk?
5. Pour boiling water in cup
6. Fill kettle
7. Stir
8. Ready
9. Add sugar ?
10. Fetch cup
Algorithm:
1. Fill kettle
2. Boil the water
3. Fetch cup
4. Put tea bag in cup
5. Pour boiling water in cup
6. Take tea bag out of cup
7. Add sugar ?
8. Stir
9. Add milk?
10. Stir
11. Ready
Example 2:
Grade students to identify pass & fail.
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”
endif
Example 3
Write an algorithm and draw a flowchart that will read the two sides of a rectangle and
calculate its area.
Pseudocode
1. Input the width (W) and Length (L) of a rectangle
2. Calculate the area (A) by multiplying L with W
3. Print A
Algorithm
Step 1: Input W,L
Step 2: A  L x W
Step 3: Print A
Pseudocode for three constructs:
Flowcharts for three constructs

More Related Content

PPTX
Algorithm Design & Implementation
PPTX
Algorithms, flow charts and pseudocodes
PPT
pseudo code basics
PPT
3 algorithm-and-flowchart
PPTX
Algorithm and flowchart
PPTX
Flowchart and algorithm
PPTX
Algorithm and pseudo codes
PPTX
Programming flowcharts for C Language
Algorithm Design & Implementation
Algorithms, flow charts and pseudocodes
pseudo code basics
3 algorithm-and-flowchart
Algorithm and flowchart
Flowchart and algorithm
Algorithm and pseudo codes
Programming flowcharts for C Language

What's hot (20)

PDF
Basic+machine+organization
PPTX
Compilers
PPT
High level and Low level Language
PDF
Graphical programming
PPTX
What is an algorithm?
PPTX
Introduction to Operating Systems
PPTX
Programming language
PPTX
Lexical analysis - Compiler Design
PPTX
Introduction to Software Engineering & Information Technology
PPTX
register
PDF
Introduction to algorithms
PPTX
System software
PPTX
Algorithms and Flowcharts
PPT
Lect 1. introduction to programming languages
PPTX
Presentation on Logical Operators
PPTX
Algorithm and Flowcharts
PDF
Computer Programming
PDF
3. basic organization of a computer
PPTX
Algorithm Introduction
PPTX
Basic+machine+organization
Compilers
High level and Low level Language
Graphical programming
What is an algorithm?
Introduction to Operating Systems
Programming language
Lexical analysis - Compiler Design
Introduction to Software Engineering & Information Technology
register
Introduction to algorithms
System software
Algorithms and Flowcharts
Lect 1. introduction to programming languages
Presentation on Logical Operators
Algorithm and Flowcharts
Computer Programming
3. basic organization of a computer
Algorithm Introduction
Ad

Viewers also liked (20)

PPTX
Number+system (1)
PDF
Dld lecture module 06
DOCX
English 01 application
PDF
Dld lecture module 02
PDF
PDF
Artificial intelligence
PDF
PDF
Dld lecture module 05
PDF
Complement
PDF
Dld lecture module 03
PDF
Dld lecture module 01
DOCX
Operating Systems
PDF
Dld lecture module 04 01
PDF
Computer graphics
PPTX
PPTX
PDF
An introduction to software
PDF
Notes of programming
PPTX
Boolean+logic
Number+system (1)
Dld lecture module 06
English 01 application
Dld lecture module 02
Artificial intelligence
Dld lecture module 05
Complement
Dld lecture module 03
Dld lecture module 01
Operating Systems
Dld lecture module 04 01
Computer graphics
An introduction to software
Notes of programming
Boolean+logic
Ad

Similar to Algorithm defination, design & Implementation (20)

PPTX
Algorithms and flowcharts by Haseeb Khan
PDF
algorithms and flow chart overview.pdf
PPT
Algorithms and Flowchart for IGCSE Students
PPT
Fundamentals of Programming Chapter 3
PPT
Lecture_01-Problem_Solving[1]||ProgrammingFundamental.ppt
PPT
Algorithms and Flowchart.ppt
PPT
Algorithms and Flowchart usages in C laguage
PPTX
Lesson 1 of c programming algorithms and flowcharts.pptx
PPT
BCE L-2 Algorithms-and-Flowchart-ppt.ppt
PPT
Lect1-Detailed description aboutAlgorithms-and-Flowchart.ppt
PDF
AlgorithmAndFlowChart.pdf
PPTX
Data Structures_Introduction to algorithms.pptx
PPT
Lecture1-Algorithms-and-Flowcharts-ppt.ppt
PPT
Lecture1-Algorithms-and-Flowchart-ppt.ppt
PPT
Lect1-Algorithms-and-Flowchart PPT presentation
PPT
Lect1-Algorithms-and-Flowchart-ppt (1).ppt
PPT
Lecture1-Algorithms-and-Flowchart-ppt.ppt
PPT
Lect1 - Algorithms-and-Flowchart-ppt.ppt
PPT
Basic Slides on Algorithms and Flowcharts
PPTX
Algorithms and flowcharts
Algorithms and flowcharts by Haseeb Khan
algorithms and flow chart overview.pdf
Algorithms and Flowchart for IGCSE Students
Fundamentals of Programming Chapter 3
Lecture_01-Problem_Solving[1]||ProgrammingFundamental.ppt
Algorithms and Flowchart.ppt
Algorithms and Flowchart usages in C laguage
Lesson 1 of c programming algorithms and flowcharts.pptx
BCE L-2 Algorithms-and-Flowchart-ppt.ppt
Lect1-Detailed description aboutAlgorithms-and-Flowchart.ppt
AlgorithmAndFlowChart.pdf
Data Structures_Introduction to algorithms.pptx
Lecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowchart-ppt.ppt
Lect1-Algorithms-and-Flowchart PPT presentation
Lect1-Algorithms-and-Flowchart-ppt (1).ppt
Lecture1-Algorithms-and-Flowchart-ppt.ppt
Lect1 - Algorithms-and-Flowchart-ppt.ppt
Basic Slides on Algorithms and Flowcharts
Algorithms and flowcharts

More from Bilal Maqbool ツ (18)

PPTX
Lecture 3 report writtng
PPTX
PPTX
Lecture 1 report writing
DOCX
Bill gates
DOCX
Programming assignment 02 (bilal maqbool 10) 2011
DOCX
Programming assignment 30 12-11
PPTX
Internet presentation
DOCX
Presentation internet programming report
DOCX
Magnetic storage devices
DOCX
How internet technology be used to spread scientific awareness among pakistan...
DOCX
Math assignment Program
DOCX
Final of sentences PPT
DOCX
Advantages and disadvantages of LCD
DOCX
A history of windows
PPTX
Bluetooth 27 01-12 PPT
DOCX
Bluetooth PPT Report
DOCX
Computing assignment 02 ms access (bilal maqbool 10) se-i
Lecture 3 report writtng
Lecture 1 report writing
Bill gates
Programming assignment 02 (bilal maqbool 10) 2011
Programming assignment 30 12-11
Internet presentation
Presentation internet programming report
Magnetic storage devices
How internet technology be used to spread scientific awareness among pakistan...
Math assignment Program
Final of sentences PPT
Advantages and disadvantages of LCD
A history of windows
Bluetooth 27 01-12 PPT
Bluetooth PPT Report
Computing assignment 02 ms access (bilal maqbool 10) se-i

Recently uploaded (20)

PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
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
TR - Agricultural Crops Production NC III.pdf
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
Cell Types and Its function , kingdom of life
PPTX
Pharma ospi slides which help in ospi learning
PDF
Complications of Minimal Access Surgery at WLH
PDF
01-Introduction-to-Information-Management.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
GDM (1) (1).pptx small presentation for students
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Sports Quiz easy sports quiz sports quiz
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
PPH.pptx obstetrics and gynecology in nursing
102 student loan defaulters named and shamed – Is someone you know on the list?
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
TR - Agricultural Crops Production NC III.pdf
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Microbial disease of the cardiovascular and lymphatic systems
Cell Types and Its function , kingdom of life
Pharma ospi slides which help in ospi learning
Complications of Minimal Access Surgery at WLH
01-Introduction-to-Information-Management.pdf
human mycosis Human fungal infections are called human mycosis..pptx
GDM (1) (1).pptx small presentation for students
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Sports Quiz easy sports quiz sports quiz
O7-L3 Supply Chain Operations - ICLT Program
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Abdominal Access Techniques with Prof. Dr. R K Mishra
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPH.pptx obstetrics and gynecology in nursing

Algorithm defination, design & Implementation

  • 1. WHAT IS AN ALGORITHM? It is a set of instructions of how to carry out a process. An algorithm lists the steps that must be followed to complete the process and to reach the solution Examples: • A knitting pattern • A set of instructions telling you how to put a kit together (eg. an kitchen unit) • A recipe in a cook book • An algorithm can be represented diagrammatically in the form of a flow chart. Algorithm constructions: There are three different constructions of algorithms.
  • 2. Properties of Algorithms: • An algorithm is an exact specification of how to solve a computational problem • An algorithm must specify every step completely, so a computer can implement it without any further “understanding” • An algorithm must work for all possible inputs of the problem. • Algorithms must be:  Correct: For each input produce an appropriate output  Efficient: run as quickly as possible, and use as little memory as possible – more about this later • There can be many different algorithms for each computational problem. Algorithms Phases: A typical programming task can be divided into two phases: 1. Problem solving phase (Designing) • produce an ordered sequence of steps that describe solution of problem • this sequence of steps is called an algorithm 2. Implementation phase • implement the program in some programming language Problem solving phase (Designing) : Steps in Problem Solving • First produce a general algorithm (one can use pseudocode) • Refine the algorithm successively to get step by step detailed algorithm that is very close to a computer language.
  • 3. • Pseudocode is an artificial and informal language that helps programmers develop algorithms. Pseudocode is very similar to everyday English. Pseudocode Example: Example 1: 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” The Flowchart: • (Dictionary) A schematic representation of a sequence of operations, as in a manufacturing process or computer program. • (Technical) A graphical representation of the sequence of operations in an information system or program. Information system flowcharts show how data flows from source documents through the computer to final distribution to users. Program flowcharts show the sequence of instructions in a single program or subroutine. Different symbols are used to draw each type of flowchart. • shows logic of an algorithm • emphasizes individual steps and their interconnections • e.g. control flow from one action to the next
  • 4. Flowchart Symbols: • A flowchart consists of a sequence of instructions linked together by arrows to show the order in which the instructions must be carried out. • It provides detailed steps. • Each instruction is put into a box. The boxes are different shapes depending upon what the instruction is. Oval Parallelogram Rectangle Diamond Hybrid Name Symbol Use in Flowchart Denotes the beginning or end of the program Denotes an input operation Denotes an output operation Denotes a decision (or branch) to be made. The program should continue along one of two routes. (e.g. IF/THEN/ELSE) Denotes a process to be carried out e.g. addition, subtraction, division etc. Flow line Denotes the direction of logic flow in the program
  • 5. Example 1: MAKING A CUP OF TEA! Pseudocode: 1. Take tea bag out of cup 2. Boil the water 3. Put tea bag in cup 4. Add milk? 5. Pour boiling water in cup 6. Fill kettle 7. Stir 8. Ready 9. Add sugar ? 10. Fetch cup Algorithm: 1. Fill kettle 2. Boil the water 3. Fetch cup 4. Put tea bag in cup 5. Pour boiling water in cup 6. Take tea bag out of cup 7. Add sugar ? 8. Stir 9. Add milk? 10. Stir 11. Ready
  • 6. Example 2: Grade students to identify pass & fail. 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” endif Example 3 Write an algorithm and draw a flowchart that will read the two sides of a rectangle and calculate its area. Pseudocode 1. Input the width (W) and Length (L) of a rectangle 2. Calculate the area (A) by multiplying L with W 3. Print A Algorithm Step 1: Input W,L Step 2: A  L x W Step 3: Print A
  • 7. Pseudocode for three constructs: Flowcharts for three constructs