Types of algorithms, ways to present them and practice
Lessons 10–11 · 2 lessons · M. R. Fayziyeva, D. M. Sayfurov, N. S. Xaytullayeva. Informatics and Information Technologies, Grade 9. “Nashriyot uyi Tasvir”, Tashkent, 2020
10
Types of algorithms and ways to present them
Textbook: pp. 30–34
GoalKnows the five ways to present an algorithm (words, formulas, table, graphic/flowchart, program) and tells the main flowchart blocks apart.
New words
flowchart: an algorithm drawn as blocks joined by arrows · blok-sxemablock: a shape in a flowchart standing for one kind of action · bloktabular algorithm: values or actions arranged in a table (timetable, table of values) · jadval ko‘rinishidagi algoritmprogram: an algorithm written in a language the computer understands · dastur
Explanation
An algorithm can be presented in five ways. In words: each instruction is a short command sentence. With formulas: the actions are given as mathematical formulas (handy for physics and chemistry problems). As a table: like a timetable or a table of values for y = x² – 3. In graphic form: a diagram, drawing, graph and above all a flowchart. As a program: the algorithm is written in a programming language. In a flowchart an oval stands for the start and end, a parallelogram for input and output, a rectangle for calculation and assignment, a rhombus (diamond) for a condition (with “yes” and “no” branches), a hexagon for a loop parameter, and a rectangle with side lines for a subprogram; the blocks are joined by lines with arrows. Because a flowchart is easy to see, it is widely used when preparing to program.
Worked examples
Algorithm for the volume and surface area of a cube. In words: 1) start; 2) input the edge a; 3) compute V = a · a · a; 4) compute S = 6 · a · a; 5) output V and S; 6) end. As a flowchart: oval (start) → parallelogram (a) → rectangle (V, S) → parallelogram (output V, S) → oval (end).
As a table: for y = x² – 3 and x = –2, –1, 0, 1, 2 we get y = 1, –2, –3, –2, 1. As a formula: the weight force near the Earth’s surface is F = m · g. As a program this kind of algorithm will be written in Python in later lessons.
Class activity
“One algorithm – five forms”: a group prepares the algorithm “enter the room and switch on the light” as words, a flowchart and a table; the others point out the differences.
Practice
1
List the five ways to present an algorithm.
Words, formulas, table, graphic form (flowchart), program.
2
Which shape tests a condition in a flowchart and how many ways lead out of it?
The rhombus; two ways – “yes” and “no”.
3
Find the area of a circle of radius 10 with S = 3.14 · R².
314
4
Why is a flowchart useful before programming?
The algorithm is visible, logical mistakes are easier to find in advance, and it does not depend on a programming language.