AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Contents · Computing

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
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.
Startpriceprice > 100 000yesnopay = price – price · 5 / 100pay = pricepayEnd
The purchase is 120 000 so‘m. Flowchart: start → input price → price > 100 000? → “yes”: pay = price – price · 5 / 100; “no”: pay = price → output pay → end. Since 120 000 > 100 000, pay = 120 000 – 6 000 = 114 000 so‘m.
Class activity

“Executor test”: one group invents an executor and its instruction set; another group writes an algorithm that solves a task with that set.

Practice
1
An executor knows the commands {+3; ×2; –4}. Write an algorithm that makes 22 from 5.
2
A 5 % discount applies to purchases over 100 000 so‘m. How much is paid for a purchase of 120 000 so‘m?
3
Which executor fits the instruction set {take the ball; dribble the ball; pass to a teammate; throw into the basket}?
4
Why can’t you give the command “up” to an executor with {right; left}?
Story of the Week · The Khwarizmi WayChecking the first runClose the week: all of this week’s subjects in one storyRead →