The document discusses algorithms and different ways to represent them, including through flowcharts, pseudocode, and decision tables. It provides examples of each representation type and explains the key components and steps in constructing a flowchart, pseudocode, and decision table to model an algorithm for determining a student's final grade.
Programming aids- Algorithm, Flowchart, Pseudocodes and Decision table
1. For more updates join our newsletter at www.anjalitechnosoft.in
A
www.anjalitechnosoft.inwww.anjalitechnosoft.in
2. For more updates join our newsletter at www.anjalitechnosoft.in
Contents
• Algorithm
• Flowchart
• Pseudo codes
• Decision Table
3. For more updates join our newsletter at www.anjalitechnosoft.in
• A typical programming task can be divided into
two phases:
• Problem solving phase
– produce an ordered sequence of steps that describe
solution of problem
– this sequence of steps is called an algorithm
• Implementation phase
– implement the program in some programming
language
Introduction
4. For more updates join our newsletter at www.anjalitechnosoft.in4
• An algorithm is “a finite set of precise
instructions for performing a computation or
for solving a problem”
– A program is one type of algorithm
• All programs are algorithms
• Not all algorithms are programs!
– Directions to somebody’s house is an algorithm
– A recipe for cooking a cake is an algorithm
– The steps to compute the cosine of 90° is an
algorithm
What is an Algorithm
5. For more updates join our newsletter at www.anjalitechnosoft.in5
• Input: what the algorithm takes in as input
• Output: what the algorithm produces as output
• Definiteness: the steps are defined precisely
• Correctness: should produce the correct output
• Finiteness: the steps required should be finite
• Effectiveness: each step must be able to be
performed in a finite amount of time
• Generality: the algorithm should be applicable
to all problems of a similar form
Properties of Algorithm
6. For more updates join our newsletter at www.anjalitechnosoft.in
• 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.
Steps in Problem Solving
7. For more updates join our newsletter at www.anjalitechnosoft.in
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.
Example
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”
8. For more updates join our newsletter at www.anjalitechnosoft.in
• 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
Example..
9. For more updates join our newsletter at www.anjalitechnosoft.in
• (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.
Flowchart
10. For more updates join our newsletter at www.anjalitechnosoft.in
Flowchart..
A Flowchart
– shows logic of an algorithm
– emphasizes individual steps and their
interconnections
– e.g. control flow from one action to the next
11. For more updates join our newsletter at www.anjalitechnosoft.in
Flowchart Symbols
12. For more updates join our newsletter at www.anjalitechnosoft.in
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
PRINT
“PASS”
START
Input
M1,M2,M3,M4
GRADE←(M1+M2+M3+M4)/4
IS
GRADE<5
0
PRINT
“FAIL”
STOP
YN
Example
13. For more updates join our newsletter at www.anjalitechnosoft.in
• A matrix representation of the logic of a decision
• Specifies the possible conditions and the resulting
actions
• Best used for complicated decision logic
Decision Table
14. For more updates join our newsletter at www.anjalitechnosoft.in
• A matrix representation of the logic of a decision
• Specifies the possible conditions and the resulting
actions
• Best used for complicated decision logic
Decision Table ..
15. For more updates join our newsletter at www.anjalitechnosoft.in
• Consists of three parts
– Condition stubs
• Lists condition relevant to decision
– Action stubs
• Actions that result from a given set of conditions
– Rules
• Specify which actions are to be followed for a given
set of conditions
16. For more updates join our newsletter at www.anjalitechnosoft.in
• Indifferent Condition
– Condition whose value does not affect which action is taken
for two or more rules
• Standard procedure for creating decision tables
– Name the condition and values each condition can assume
– Name all possible actions that can occur
– List all rules
– Define the actions for each rule
– Simplify the table
17. For more updates join our newsletter at www.anjalitechnosoft.in
9.17
18. For more updates join our newsletter at www.anjalitechnosoft.in
• PART 1. FRAME THE PROBLEM.
– Identify the conditions (decision criteria). These are the factors that will influence the
decision.
• E.g., We want to know the total cost of a student’s tuition. What factors are important?
– Identify the range of values for each condition or criteria.
• E.g. What are they for each factor identified above?
– Identify all possible actions that can occur.
• E.g. What types of calculations would be necessary?
• PART 2. CREATE THE TABLE.
– Create a table with 4 quadrants.
• Put the conditions in the upper left quadrant. One row per condition.
• Put the actions in the lower left quadrant. One row per action.
– List all possible rules.
• Alternate values for first condition. Repeat for all values of second condition. Keep repeating
this process for all conditions.
• Put the rules in the upper right quadrant.
– Enter actions for each rule
• In the lower right quadrant, determine what, if any, appropriate actions should be taken for
each rule.
– Reduce table as necessary.
Construction a Decision Table
19. For more updates join our newsletter at www.anjalitechnosoft.in
For any enquiry, post your doubt at
Anjali Technosoft
@ Clear your Doubts
For any enquiry, post your doubt at
Anjali Technosoft
@ Clear your Doubts