1. ALGORITHM, PSEUDOCODE AND FLOW CHART
BY: SATVEER KAUR, ASSISTANT PROFESSOR, KHALSA COLLEGE, PATIALA 1
2. ALGORITHM
A finite set of steps that specify a sequence of operations to be carried out in order to solve a specific
problem.
It consists a set of explicit and clearly defined finite steps to carry out for a given set of initial conditions,
produce the corresponding output and terminate after a fixed amount of time.
Tells the computer to solve the problem in a systematic way to get the desired output.
BY: SATVEER KAUR, ASSISTANT PROFESSOR, KHALSA COLLEGE, PATIALA 2
3. CHARACTERISTICS OR PROPERTIES OF ALGORITHMS
Finiteness- must terminate in finite number of steps.
Simplicity- Should be simple and easy to read.
Absence of Ambiguity- each step must be clear and unambiguous.
Feasibility- each step must be simple enough that it can be easily translated into the required language.
Completeness and correctness- must be complete and correct.
Input-These are zero or more values which are externally supplied to the algorithm.
Output-At least one value is produced.
BY: SATVEER KAUR, ASSISTANT PROFESSOR, KHALSA COLLEGE, PATIALA 3
4. STEPS TO WRITE ALGORITHM
Start the algorithm.
Take input from user.
Process the input data.
Produce one or more results after processing.
Show the result.
Exit the algorithm.
BY: SATVEER KAUR, ASSISTANT PROFESSOR, KHALSA COLLEGE, PATIALA 4
5. VERIFYING THE ALGORITHMS
To ensure the efficient execution of program, it is necessary to verify the algorithm before converting it
into a computer program.
Different methods to verify are:
Dry run: find the value of each variable manually after every step.
Review: studying the logic and computing with a specification.
Walk through: presented to the team member for checking the efficiency.
BY: SATVEER KAUR, ASSISTANT PROFESSOR, KHALSA COLLEGE, PATIALA 5
6. EXAMPLE FOR AN ALGORITHM
Add two numbers.
Step 1: Start algorithm.
Step 2: Enter two numbers a, b.
Step 3: Compute c = a + b.
Step 4: Print c.
Step 5: Exit.
BY: SATVEER KAUR, ASSISTANT PROFESSOR, KHALSA COLLEGE, PATIALA 6
7. FLOW CHART
A pictorial representation of problem and algorithms to its solution that uses the symbols connected by
flow lines.
Called flow chart because it charts the flow of program.
Used in expressing and understanding algorithms.
Useful for the programmer and system analyst.
BY: SATVEER KAUR, ASSISTANT PROFESSOR, KHALSA COLLEGE, PATIALA 7
8. SYMBOLS USED FOR FLOW CHART
The terminator symbol:
represented by rectangle by rounded ends.
Indicates the start and stop of the flow chart.
Input output symbol:
Represented by parallelogram.
Indicates input output operation.
BY: SATVEER KAUR, ASSISTANT PROFESSOR, KHALSA COLLEGE, PATIALA 8
9. SYMBOLS USED FOR FLOW CHART
Decision symbol:
Represented by diamond.
Used to check the conditions whether true or false.
Depending upon the condition, the program branches into direction.
Process symbol:
Represented by rectangle.
Indicates any processing, operation, calculation etc.
BY: SATVEER KAUR, ASSISTANT PROFESSOR, KHALSA COLLEGE, PATIALA 9
10. SYMBOLS USED FOR FLOW CHART
Connector symbol:
Represented using a circle.
Brings together two branches of a program.
Connects various pages of long flow charts.
Predefined Process symbol:
Represented using process symbol ( rectangle with two lines one on left and one on right side).
Indicates a module of a program already defined by another flow chart.
BY: SATVEER KAUR, ASSISTANT PROFESSOR, KHALSA COLLEGE, PATIALA 10
11. SYMBOLS USED FOR FLOW CHART
Document symbol:
Represented by document symbol.
Used to represent any document on paper.
Data flow symbol:
Represented by arrows.
Indicates the flow of operation.
Also connects other symbols to one another.
BY: SATVEER KAUR, ASSISTANT PROFESSOR, KHALSA COLLEGE, PATIALA 11
12. SYMBOLS USED FOR FLOW CHART
Annotation symbol:
Represented by open-ended box connected to the chart by dotted lines.
Used for explanation or comments related to the program.
Preparation:
Represented by hexagon.
Used to control, initiate or perform some other operation on the program itself.
BY: SATVEER KAUR, ASSISTANT PROFESSOR, KHALSA COLLEGE, PATIALA 12
13. PSEUDOCODE
Consists of short, English phrases used to explain specific tasks within a program.
Is an informal high level description of the operating principle of a program or an algorithm.
Should not include keywords in any specific computer language.
Should be written as a list of consecutive phrases.
allows the designer to focus on the logic of the algorithm without being distracted by details of
language syntax.
describe the entire logic of the algorithm.
BY: SATVEER KAUR, ASSISTANT PROFESSOR, KHALSA COLLEGE, PATIALA 13
14. EXAMPLE OF PSEUDOCODE
Write a pseudocode to find sum and average of given two numbers.
Begin
WRITE “Please enter two numbers to add”
READ num1
READ num2
Sum = num1+num2
Avg = Sum/2
WRITE Sum, Avg
End
BY: SATVEER KAUR, ASSISTANT PROFESSOR, KHALSA COLLEGE, PATIALA 14