Certainly you have already realized that electronic devices, including computers, tablets or smartphones, work strictly according to the „recipes” developed by people. However, before the programmerprogrammerprogrammer enters the codecodecode into the memory of such a machine, on the basis of which it will perform the tasks assigned to it, it is necessary to carefully analyse what the device should do and in what situation. Seemingly, it seems to be simple, but when we start to create such a recipereciperecipe, which is technically called an algorithmalgorithmalgorithm, it turns out that it is complicated and many situations have to be anticipated.
Let's try to create an algorithm for ... an elevator - a device we often use.
R11Gqe8LfzACW
Zdjęcie przedstawia przyciski w windzie, rozmieszczone w dwóch kolumnach po trzy. Środkowe przyciski są nieopisane. W lewej kolumnie od góry cyfra zero, na dole ikona dzwonka. W prawej kolumnie od góry cyfra jeden, na dole ikona otwierania drzwi (trójkąt skierowany wierzchołkiem w lewą stronę, prostokąt, trójkąt skierowany wierzchołkiem w prawą stronę).
Imagine that the elevator runs only between two floors:
ground floor level,
first floor level.
Our algorithm in the simplest case will be based on the following commands:
go up,
go down,
stop the elevator,
open the door,
close the door.
And information:
the call button was pressed on the ground floor,
the call button was pressed on the first floor,
the 'to the ground floor' selection button was pressed in the elevator,
the 'to the first floor' selection button was pressed in the elevator.
And the variablevariablevariable 'storey', which will take the valuevaluevalue 'ground floor' if the elevator will be located on the ground floor or 'first floor' when it is on the first floor.
Rewrite the algorithmalgorithmalgorithm so that the elevator works as before, but in addition:
A: first it goes down to the passenger, if it was left upstairs. B: it serves both passengers going up and down. C: additionally, it serves the third storey (basement).
When you deal with the above tasks, think that the real elevator still:
reacts to the 'stop' emergency button,
takes passengers on the way from other storeys if they pressed the call button in the direction in which the elevator moves ('up or down'),
will not stop 'on the way' if there is already a maximum number of passengers in the elevator.
The commands used by you in the algorithms are written using the graphic symbols shown in the interactive picture.
R1ebDxWBzR9F4
Ilustracja interaktywna przedstawia sześć symboli graficznych, nazywanych blokami. Reprezentują one polecenia wykorzystywane przy tworzeniu algorytmów. 1 - owal, prostokąt z zaokrąglonymi rogami. 2 - prostokąt. 3 - równoległobok. 4 - romb. 5 - prostokąt z dodatkowymi pionowymi kreskami po bokach. 6 - kółko. Wybierz odpowiedni przycisk aby dowiedzieć się jaką funkcje pełnią w schemacie blokowym. Na ilustracji widoczne są numery, a na nich podpisy. 1. The beginning or end of the algorithm. {audio}, 2. The figure represents the process. Inside it, we place all calculations or substitutions. {audio}, 3. Reading or writing data. Inside the figure there are instructions on what to do. {audio}, 4. Decision block. Inside it, we place a condition that can be answered YES or NO. {audio}, 5. A process that has already been defined. {audio}, 6. Page link. We use if we want to move from one place on a page to another. {audio}
Ilustracja interaktywna przedstawia sześć symboli graficznych, nazywanych blokami. Reprezentują one polecenia wykorzystywane przy tworzeniu algorytmów. 1 - owal, prostokąt z zaokrąglonymi rogami. 2 - prostokąt. 3 - równoległobok. 4 - romb. 5 - prostokąt z dodatkowymi pionowymi kreskami po bokach. 6 - kółko. Wybierz odpowiedni przycisk aby dowiedzieć się jaką funkcje pełnią w schemacie blokowym. Na ilustracji widoczne są numery, a na nich podpisy. 1. The beginning or end of the algorithm. {audio}, 2. The figure represents the process. Inside it, we place all calculations or substitutions. {audio}, 3. Reading or writing data. Inside the figure there are instructions on what to do. {audio}, 4. Decision block. Inside it, we place a condition that can be answered YES or NO. {audio}, 5. A process that has already been defined. {audio}, 6. Page link. We use if we want to move from one place on a page to another. {audio}
An algorithmalgorithmalgorithm is a procedure that ultimately leads to a specific effect. The algorithm should be correct, finite, effective, unambiguous and universal. It means that it should cover all possible cases describing a given situation. In the end it should always give the correct result after completing the finite number of actions.
Exercises
Exercise 1
RXjBn9Onr6Gak
Wersja alternatywna ćwiczenia: Determine which sentence is true. Możliwe odpowiedzi: 1. You can create an algorithm for solving some mathematical equation., 2. You can create an algorithm for calculating the square area., 3. An algorithm can be used in any situation in real life., 4. A recipe for baking a cake can be an algorithm., 5. An algorithm is only in the graphic version., 6. It’s necessary to know one of the programming languages to write some algorithm.
Wersja alternatywna ćwiczenia: Determine which sentence is true. Możliwe odpowiedzi: 1. You can create an algorithm for solving some mathematical equation., 2. You can create an algorithm for calculating the square area., 3. An algorithm can be used in any situation in real life., 4. A recipe for baking a cake can be an algorithm., 5. An algorithm is only in the graphic version., 6. It’s necessary to know one of the programming languages to write some algorithm.
Determine which sentence is true.
You can create an algorithm for solving some mathematical equation.
You can create an algorithm for calculating the square area.
An algorithm can be used in any situation in real life.
A recipe for baking a cake can be an algorithm.
An algorithm is only in the graphic version.
It’s necessary to know one of the programming languages to write some algorithm.
zadanie
Source: GroMar, licencja: CC BY 3.0.
Exercise 2
Create a garbage sorting algorithm for your house.
Exercise 3
Write in English how to create algorithms.
Exercise 4
RVHJJBNBsTmm9
Wersja alternatywna ćwiczenia: Indicate which pairs of expressions or words are translated correctly. Możliwe odpowiedzi: 1. algorytm - algorithm, 2. instrukcja - instruction, 3. programista - programmer, 4. kod - code, 5. zmienna - value, 6. wartość - variable
Wersja alternatywna ćwiczenia: Indicate which pairs of expressions or words are translated correctly. Możliwe odpowiedzi: 1. algorytm - algorithm, 2. instrukcja - instruction, 3. programista - programmer, 4. kod - code, 5. zmienna - value, 6. wartość - variable
Indicate which pairs of expressions or words are translated correctly.
algorytm - algorithm
instrukcja - instruction
programista - programmer
kod - code
zmienna - value
wartość - variable
zadanie
Source: GroMar, licencja: CC BY 3.0.
R2GVZtaJ7daVK1
Interaktywna gra, polegająca na łączeniu wyrazów w pary w ciągu jednej minuty. Czas zaczyna upływać wraz z rozpoczęciem gry. Jeden ruch to odkrywanie najpierw jednej potem drugiej karty z wyrazem. Każdy wyraz jest odczytywany. Kolejny ruch to odkrywanie trzeciej i czwartej karty. W ten sposób odsłuchasz wszystkie wyrazy. Nawigacja z poziomu klawiatury za pomocą strzałek, odsłuchiwanie wyrazów enterem lub spacją. Znajdź wszystkie pary wyrazów.
Interaktywna gra, polegająca na łączeniu wyrazów w pary w ciągu jednej minuty. Czas zaczyna upływać wraz z rozpoczęciem gry. Jeden ruch to odkrywanie najpierw jednej potem drugiej karty z wyrazem. Każdy wyraz jest odczytywany. Kolejny ruch to odkrywanie trzeciej i czwartej karty. W ten sposób odsłuchasz wszystkie wyrazy. Nawigacja z poziomu klawiatury za pomocą strzałek, odsłuchiwanie wyrazów enterem lub spacją. Znajdź wszystkie pary wyrazów.
Match Polish terms with their English equivalents.
algorytm
kod
instruction
code
przepis
programista
instrukcja
recipe
algorithm
programmer
Source: Zespół autorski Politechniki Łódzkiej, licencja: CC BY 3.0.