Professional Documents
Culture Documents
CM304
CM304
CM304
ANDHRA PRADESH
CM304.27 1
Recap
CM304.27 2
Objective
CM304.27 3
Introduction
CM304.27 4
Informal definition of an algorithm
used in a computer
CM304.27 5
The essential properties of an algorithm ?
It should be simple.
It should be clear with no ambiguity.
It should lead to a unique solution of the
problem.
It should involve a finite number of steps to
arrive at a solution.
It should have the capability to handle some
unexpected situations which may arise during
the solution of a problem.
CM304.27 6
Steps involved in developing an algorithm:
CM304.27 7
Steps involved in developing an algorithm:
CM304.27 8
Advantages of algorithms
It is time consuming.
CM304.27 11
Problem Statement
CM304.27 12
Problem Statement
CM304.27 13
Algorithm
CM304.27 14
Algorithm
CM304.27 15
Algorithm Contd..
CM304.27 17
Algorithm
Average of two
Average Of Two
Input: Two numbers
3. Add the two numbers
4. Divide the result by 2
5. Return the result by step 2
End
CM304.27 18
Pseudocode & Algorithm
CM304.27 19
Pseudocode & Algorithm
Pseudocode:
Input a set of marks in four subjects.
Calculate their average by summing and
dividing by 4
if average is below 50
Print “FAIL”
else
Print “PASS”
CM304.27 20
Pseudocode & Algorithm
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”
endif
CM304.27 21
The Good and the Bad…
Using Algorithms Going without…..
CM304.27 22
Algorithm in Real Life
CM304.27 23
Algorithm in Real Life
CM304.27 24
‘Divide and Conquer’ Strategy in Algorithm
1. Start
2. Prepare a Breakfast
3. End
CM304.27 25
‘Divide and Conquer’ Strategy in Algorithm
1. Start
2. Prepare a Breakfast
2.1 Prepare a tuna sandwich
2.2 Prepare some chips
2.3 Make a cup of coffee
3. End
CM304.27 26
‘Divide and Conquer’ Strategy in Algorithm
1. Start
2. Prepare a Breakfast
2.1 Prepare a tuna sandwich
2.1.1 Take 2 slices of bread
2.1.2 Prepare tuna paste
2.2 Prepare some chips
2.3 Make a cup of coffee
3. End
CM304.27 27
‘Divide and Conquer’ Strategy in Algorithm
1. Start
2. Prepare a Breakfast
2.1 Prepare a tuna sandwich
2.1.1 Take 2 slices of bread
2.1.2 Prepare tuna paste
2.2 Prepare some chips
2.2.1 Cut potatoes into slices
2.2.2 Fry the potatoes
2.3 Make a cup of coffee
3. End
CM304.27 28
‘Divide and Conquer’ Strategy in Algorithm
1. Start
2. Prepare a Breakfast
2.1. Prepare a tuna sandwich
2.1.1 Take 2 slices of bread
2.1.2 Prepare tuna paste
2.2. Prepare some chips
2.2.1 Cut potatoes into slices
2.2.2 Fry the potatoes
2.3. Make a cup of coffee
2.3.1 Boil water
2.3.2 Add water with sugar and coffee
3. End
CM304.27 29
Something to ponder …
CM304.27 30
Summary
CM304.27 31
Quiz
(a) program
(b) flowchart
(c) algorithm
(d) coding
CM304.27 32
Quiz
(a) program
(b) flowchart
(c) algorithm
(d) coding
CM304.27 33
Frequently Asked Questions
3. What is an Algorithm?
CM304.27 34