ALGORITHMS AND FLOW CHARTS
An algorithm is a step-by-step procedure for solving a problem. It contains calculations, reasoning, and
data processing. Algorithms can be represented by natural languages, pseudocode, and flowcharts
Algorithms are generally divided into six fundamental types based on their function:
i) Recursive algorithm
ii) Divide and conquer algorithm
iii) Dynamic programming algorithm
iv) Greedy algorithm
v) Brute force algorithm
vi) Backtracking algorithm
A flowchart is a graphical/ pictorial representation of an algorithm consisting of symbols, shapes, and
arrows to explain a process or program flow.
Several standard symbols are applied in a flowchart:
i) Terminal box – ii) Input/ output iii) Process/ instruction
start/ end
iv) Decision v) Connector/ arrow
Flowcharts are often used as a program planning tool to organize the program’s step-by-step process
visually. Here are some examples:
1|Algorithms & Flowcharts
1) Print numbers on the screen from 1 to 20
Algorithm: Flowchart:
START
• Step 1: Initialize X as 0,
• Step 2: Increment X by 1,
• Step 3: Print X,
• Step 4: If X is less than 20 then go back to INITIALIZE
X0
step 2.
INCREMENT X BY 1
XX+1
PRINT X
YES
X < 20
NO
END
2) Convert the temperature from Fahrenheit (0F) to Celsius (0C)
Algorithm Flowchart
• Step 1: Read temperature in Fahrenheit, START
• Step 2: Calculate temperature with
formula C=5/9*(F-32),
• Step 3: Print C.
READ F
C 5/9 * (F - 32)
PRINT C
END
2|Algorithms & Flowcharts
3) Determine whether a student passed the semester or not
Algorithm Flowchart
• Step 1: Input grades of 4 courses M1, START
M2, M3, and M4,
• Step 2: Calculate the average grade
with the formula INPUT
"Grade=(M1+M2+M3+M4)/4" M1, M2, M3, M4
• Step 3: If the average grade is less than
60, print "FAIL", else print "PASS"
GRADE (M1 + M2 + M3 + M4)/4
YES GRADE < 60 NO
PRINT PRINT
FAIL PASS
END
3|Algorithms & Flowcharts