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
11
Practical lesson: presenting algorithms
Textbook: p. 34
GoalWrites an algorithm that fits an executor’s instruction set, presents it in words and as a flowchart, and calculates with a condition block.
New words
instruction set: the commands the executor is allowed to use · ko‘rsatmalar tizimicondition block: a rhombus with two exits, “yes” and “no” · shart tekshirish blokidiscount: a part of the price taken off · chegirmatrace table: a table of variable values after each step · kuzatuv jadvali
Explanation
In this practical lesson we design algorithms to fit the executor’s abilities. First write down the executor’s instruction set and then use only those commands. Writing down the result after every step (a trace table) is the easiest way to check an algorithm. Problems with a condition (for example “if the purchase is over 100 000 so‘m, take 5 % off”) need a rhombus block: the discount is computed on the “yes” branch and the price stays the same on the “no” branch. When the algorithm is ready, walk through it by hand with one or two numbers: put in the input value and pass through every block.
💡 Where will I use this?
In real life
In a school game a robot knows only three commands: forward, right and left. A group drew a way out of a maze on paper using only those commands and let each other check it.
Who uses it
Robotics engineers, game developers and automation engineers write commands that fit what the executor can do.
Try it today
Guide a friend across the room to an object using only three spoken commands, such as “step”, “turn left” and “turn right”. Clear the floor first and move slowly.
Worked examples
5×2→10+3→13×2→26–4→22
The executor’s set: {+3; ×2; –4}. To get 22 from 5: ×2 → 10; +3 → 13; ×2 → 26; –4 → 22. Trace table: 5, 10, 13, 26, 22.