SlideShare a Scribd company logo
3
Most read
6
Most read
7
Most read
Idea of Algorithm
4. algorithm
4. algorithm
Features of an Algorithm
• Must be Precise.
• Must be Unambiguous.
• Should be completed in finite number of
steps.
• No instruction must be repeated infinitely.
• Each step must follow a specified order.
• After termination, desired result must be
obtained.
4. algorithm
Example
• Test the equality of two numbers.
o Step 1: Start
o Step 2: Input first number as A
o Step 3: Input second number as B
o Step 4: if A=B
then print “Equal”
else
Print “Not Equal”
o Step 5: Stop
Example
• To print the first 10 natural numbers.
oStep 1: Start
oStep 2: [initialization] set i=1, n=10
oStep 3: Repeat step while i<=n
oStep 4: print i
oStep 5: Stop
Example
• To find sum of N natural numbers.
oStep 1: Start
oStep 2: Input N
oStep 3: [initialization] set i=1, sum=0
oStep 4: Repeat step while i<=N
oStep 5: set sum= sum+ i
Set i=i+1
oStep 4: print sum
oStep 5: Stop
Other Examples
1. Algorithm to find largest of three numbers.
2. To find whether a number is even or odd.
3. To find average of first N natural numbers.
4. To interchange / swapping of two variables.
Using/without using third variable.
5. To find area of a circle of radius r.
6. To find simple interest and compound interest for
principal p, rate r and time t.
7. To find roots of a quadratic equation.
4. algorithm
Flow Chart
• Graphical representation of steps followed to
solve a given problem.
• Flow chart helps the viewers to visualize the
logic of the solution of a problem.
• In flow chart, each step is depicted by a
symbol and is associated with a short
description.
4. algorithm
• Calculate the sum of first 10 natural numbers.
start
Set i=1 and Sum=0
Set sum=sum+i and i=i+1
Is i>10?
Display Sum
End
No
Yes
Pseudo Code
• It is a compact informal high-level description
of an algorithm that uses the structural
conventions of programming language.
• Pseudo codes are an outline of a program that
can easily be converted into programming
statements.
Keywords used while writing pseudo
codes:
1. IF (age>=18) then
display eligible to vote
ELSE
display not eligible
END IF
2. WHILE (i<10)
print i
increment i by 1
END WHILE
3. FOR each student in the class
add 10 as bonus marks
END FOR

More Related Content

PDF
Flowchart design for algorithms
PPTX
Programming Paradigm & Languages
PDF
Graphical programming
PPT
File handling in c
PPTX
C language ppt
PPTX
C tokens
PPT
pseudo code basics
PPT
Formal Specifications in Formal Methods
Flowchart design for algorithms
Programming Paradigm & Languages
Graphical programming
File handling in c
C language ppt
C tokens
pseudo code basics
Formal Specifications in Formal Methods

What's hot (20)

PPTX
Question answer
PPT
Introduction to Compiler design
PPTX
Servlets api overview
PPTX
Std 10 computer chapter 10 introduction to c language (part1)
PPTX
Algorithm and flowchart
PPTX
Computer Organization and Architecture.pptx
PPTX
Programming Fundamentals
PPTX
Specification-of-tokens
PPTX
Python dictionary
PPT
Lect 1. introduction to programming languages
PPTX
Pseudocode
PPTX
CPU Scheduling in OS Presentation
PDF
Python If Else | If Else Statement In Python | Edureka
PDF
Python programming : Arrays
PPTX
Compiler vs interpreter
PPTX
Conditional Statement in C Language
PPTX
Data types in C language
PPTX
Function in c
PPTX
functions of C++
PPTX
Lock based protocols
Question answer
Introduction to Compiler design
Servlets api overview
Std 10 computer chapter 10 introduction to c language (part1)
Algorithm and flowchart
Computer Organization and Architecture.pptx
Programming Fundamentals
Specification-of-tokens
Python dictionary
Lect 1. introduction to programming languages
Pseudocode
CPU Scheduling in OS Presentation
Python If Else | If Else Statement In Python | Edureka
Python programming : Arrays
Compiler vs interpreter
Conditional Statement in C Language
Data types in C language
Function in c
functions of C++
Lock based protocols
Ad

Similar to 4. algorithm (20)

PPTX
Std 10 computer chapter 9 Problems and Problem Solving
PDF
Introduction to programming : flowchart, algorithm
PDF
Logic Development and Algorithm.
PDF
C language algorithms
PDF
algorithm
DOCX
CLASS VIII COMPUTERS FLOW CHART AND ALGORITHM
PPT
Cs 1114 - lecture-10
PPT
algorithm_practice.pptzkkxiqdhiwdowhdohwod2hodh2odh2o
PPTX
Lecture 7.pptx
PPTX
Computer Studies 2013 Curriculum framework 11 Notes ppt.pptx
PPTX
UNIT 1.pptx Programming for Problem Solving
PPTX
UNIT I - Algorithmic Problem Solving.pptx
PPTX
Insider mathematical
DOCX
C_Lab Manual_Part A.docx
PPTX
UNIT I_PSPP - Illustrative Problems (1).pptx
PPTX
C PROGRAMMING document for beginners....
PDF
Basics of Algorithm Unit 1 part 1 algorithm
PPTX
Csci101 lect03 algorithms_i
PPTX
Flowchart and algorithm
DOCX
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docx
Std 10 computer chapter 9 Problems and Problem Solving
Introduction to programming : flowchart, algorithm
Logic Development and Algorithm.
C language algorithms
algorithm
CLASS VIII COMPUTERS FLOW CHART AND ALGORITHM
Cs 1114 - lecture-10
algorithm_practice.pptzkkxiqdhiwdowhdohwod2hodh2odh2o
Lecture 7.pptx
Computer Studies 2013 Curriculum framework 11 Notes ppt.pptx
UNIT 1.pptx Programming for Problem Solving
UNIT I - Algorithmic Problem Solving.pptx
Insider mathematical
C_Lab Manual_Part A.docx
UNIT I_PSPP - Illustrative Problems (1).pptx
C PROGRAMMING document for beginners....
Basics of Algorithm Unit 1 part 1 algorithm
Csci101 lect03 algorithms_i
Flowchart and algorithm
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docx
Ad

More from SHIKHA GAUTAM (17)

PDF
Agreement Protocols, distributed File Systems, Distributed Shared Memory
PPTX
Distributed Mutual Exclusion and Distributed Deadlock Detection
PPTX
Distributed Systems Introduction and Importance
PDF
PDF
PDF
Unit iii
PDF
Unit ii_KCS201
DOCX
Type conversion in c
PDF
C intro
PDF
3. basic organization of a computer
PDF
Generations of computer
PDF
c_programming
PPTX
Data Mining
PPTX
Warehouse Planning and Implementation
PPTX
Data Warehousing
PPTX
Dbms Introduction and Basics
PPTX
Agreement Protocols, distributed File Systems, Distributed Shared Memory
Distributed Mutual Exclusion and Distributed Deadlock Detection
Distributed Systems Introduction and Importance
Unit iii
Unit ii_KCS201
Type conversion in c
C intro
3. basic organization of a computer
Generations of computer
c_programming
Data Mining
Warehouse Planning and Implementation
Data Warehousing
Dbms Introduction and Basics

Recently uploaded (20)

PDF
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
PPTX
COMPUTERS AS DATA ANALYSIS IN PRECLINICAL DEVELOPMENT.pptx
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PPTX
Open Quiz Monsoon Mind Game Prelims.pptx
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
Open Quiz Monsoon Mind Game Final Set.pptx
PDF
01-Introduction-to-Information-Management.pdf
PPTX
NOI Hackathon - Summer Edition - GreenThumber.pptx
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
COMPUTERS AS DATA ANALYSIS IN PRECLINICAL DEVELOPMENT.pptx
O5-L3 Freight Transport Ops (International) V1.pdf
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
102 student loan defaulters named and shamed – Is someone you know on the list?
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Anesthesia in Laparoscopic Surgery in India
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
Open Quiz Monsoon Mind Game Prelims.pptx
Renaissance Architecture: A Journey from Faith to Humanism
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Open Quiz Monsoon Mind Game Final Set.pptx
01-Introduction-to-Information-Management.pdf
NOI Hackathon - Summer Edition - GreenThumber.pptx
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
2.FourierTransform-ShortQuestionswithAnswers.pdf
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
human mycosis Human fungal infections are called human mycosis..pptx
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...

4. algorithm

  • 4. Features of an Algorithm • Must be Precise. • Must be Unambiguous. • Should be completed in finite number of steps. • No instruction must be repeated infinitely. • Each step must follow a specified order. • After termination, desired result must be obtained.
  • 6. Example • Test the equality of two numbers. o Step 1: Start o Step 2: Input first number as A o Step 3: Input second number as B o Step 4: if A=B then print “Equal” else Print “Not Equal” o Step 5: Stop
  • 7. Example • To print the first 10 natural numbers. oStep 1: Start oStep 2: [initialization] set i=1, n=10 oStep 3: Repeat step while i<=n oStep 4: print i oStep 5: Stop
  • 8. Example • To find sum of N natural numbers. oStep 1: Start oStep 2: Input N oStep 3: [initialization] set i=1, sum=0 oStep 4: Repeat step while i<=N oStep 5: set sum= sum+ i Set i=i+1 oStep 4: print sum oStep 5: Stop
  • 9. Other Examples 1. Algorithm to find largest of three numbers. 2. To find whether a number is even or odd. 3. To find average of first N natural numbers. 4. To interchange / swapping of two variables. Using/without using third variable. 5. To find area of a circle of radius r. 6. To find simple interest and compound interest for principal p, rate r and time t. 7. To find roots of a quadratic equation.
  • 11. Flow Chart • Graphical representation of steps followed to solve a given problem. • Flow chart helps the viewers to visualize the logic of the solution of a problem. • In flow chart, each step is depicted by a symbol and is associated with a short description.
  • 13. • Calculate the sum of first 10 natural numbers. start Set i=1 and Sum=0 Set sum=sum+i and i=i+1 Is i>10? Display Sum End No Yes
  • 14. Pseudo Code • It is a compact informal high-level description of an algorithm that uses the structural conventions of programming language. • Pseudo codes are an outline of a program that can easily be converted into programming statements.
  • 15. Keywords used while writing pseudo codes: 1. IF (age>=18) then display eligible to vote ELSE display not eligible END IF
  • 16. 2. WHILE (i<10) print i increment i by 1 END WHILE 3. FOR each student in the class add 10 as bonus marks END FOR