The villager has to transport a wolf, a goat and a cabbage across the river. The boat, however, is so small that only a villager and one of the three can fit into it. If he leaves the wolf with the goat, the wolf will devour the goat. If he leaves the goat with the cabbage, the goat will eat the cabbage. How can a villager handle the transport?
Write down the recipereciperecipe to solve this puzzle.
You should start with the goat. The villager transports the goat, then returns for the wolf. Then he transports the wolf to the other side of the river. From there he takes the goat back, leaves it on the riverbank, where he started. He takes the cabbage and transports it across the river. At the end he returns for the goat.
Draw a flowchartflowchartflowchart for the recipereciperecipe for cooking boiled eggs.
Put the egg in boiling water.
Note the initial time tIndeks dolny 00
Read the current time t.
Calculate Δt = t - tIndeks dolny 00
If Δt <3 min., go to step 3.
Remove the egg from the boiling water.
End the algorithm.
Modify the commandcommandcommand depending on if you want to cook either boiled egg or soft‑boiled egg. The soft boiled egg is boiled for less than 3 minutes.
Analyse the algorithmalgorithm algorithm below and list the consecutive steps that are being implemented. Specify the problem that the indicated algorithm applies to.
R1EEUMJEk7BaW
Na rysunku znajduje się schemat blokowy algorytmu. Zaczyna się owalem z napisem START. Strzałka w dół prowadzi do równoległoboku z napisem Enter a number. Strzałka w dół prowadzi do rombu z napisem Is the number even? Strzałka od rombu w lewo i w dół podpisana NO prowadzi do równoległoboku z napisem Display "the number is not divisible by 6". Strzałka od rombu w prawo i w dół podpisana YES prowadzi do drugiego rombu z napisem Is the number divisible by 3? Strzałka od drugiego rombu w prawo i w dół podpisana YES prowadzi do równoległoboku z napisem Display "the number is divisible by 6". Strzałka lewo podpisana NO prowadzi do pierwszego równoległoboku z napisem Display "the number is not divisible by 6". Z obu równoległoboków z napisem Display ... strzałki prowadzą do owalu z napisem END.
Analyse the interactive picture and see what steps are performed during the implementation of the algorithm when finding the largest common divisor.
R1H1G0s5mPlUn
Ilustracja interaktywna przedstawia schemat blokowy algorytmu Euklidesa, służący do znalezienia największego wspólnego dzielnika. Na rysunku znajdują się bloki oznaczone numerami od 1 do 6. Na górze owal z napisem START. Strzałka w dół prowadzi do równoległoboku oznaczonego cyfrą 1, z napisem Enter numbers A and B. Strzałka w dół prowadzi do rombu oznaczonego cyfrą 2, z napisem A different from B? Strzałka wychodząca w prawo i w dół podpisana YES prowadzi do rombu oznaczonego cyfrą 3, z napisem A > B ? Strzałka w lewo i w dół podpisana NO prowadzi do prostokąta oznaczonego cyfrą 4, z napisem B=B-A. Od rombu 3 strzałka w prawo i w dół podpisana YES prowadzi do prostokąta oznaczonego cyfrą 5, z napisem A=A-B. Od obu prostokątów oznaczonych 4 i 5 strzałki prowadzą ponownie do rombu oznaczonego 2. Z rombu oznaczonego 2 wychodząca strzałka w lewo i w dół podpisana NO prowadzi do równoległoboku z napisem Display "A". Od równoległoboku strzałka e dół prowadzi do owalu oznaczonego liczbą 6, z napisem END. Na ilustracji widoczne są numery, a na nich podpisy. 1. Enter the numbers A and B. {audio}, 2. Check if the numbers A and B are equal. If so, the number A which is the same as the number B is the least common denominator, if not go to 3. {audio}, 3. Check which number is greater. Depending on the answer, perform actions 4 or 5. {audio}, 4. For the number B substitute the differences between the numbers B and A and retry the commands starting from 2. {audio}, 5. For the number A substitute the differences between the numbers A and B and retry the commands starting from 2. {audio}, 6. End. {audio}
Ilustracja interaktywna przedstawia schemat blokowy algorytmu Euklidesa, służący do znalezienia największego wspólnego dzielnika. Na rysunku znajdują się bloki oznaczone numerami od 1 do 6. Na górze owal z napisem START. Strzałka w dół prowadzi do równoległoboku oznaczonego cyfrą 1, z napisem Enter numbers A and B. Strzałka w dół prowadzi do rombu oznaczonego cyfrą 2, z napisem A different from B? Strzałka wychodząca w prawo i w dół podpisana YES prowadzi do rombu oznaczonego cyfrą 3, z napisem A > B ? Strzałka w lewo i w dół podpisana NO prowadzi do prostokąta oznaczonego cyfrą 4, z napisem B=B-A. Od rombu 3 strzałka w prawo i w dół podpisana YES prowadzi do prostokąta oznaczonego cyfrą 5, z napisem A=A-B. Od obu prostokątów oznaczonych 4 i 5 strzałki prowadzą ponownie do rombu oznaczonego 2. Z rombu oznaczonego 2 wychodząca strzałka w lewo i w dół podpisana NO prowadzi do równoległoboku z napisem Display "A". Od równoległoboku strzałka e dół prowadzi do owalu oznaczonego liczbą 6, z napisem END. Na ilustracji widoczne są numery, a na nich podpisy. 1. Enter the numbers A and B. {audio}, 2. Check if the numbers A and B are equal. If so, the number A which is the same as the number B is the least common denominator, if not go to 3. {audio}, 3. Check which number is greater. Depending on the answer, perform actions 4 or 5. {audio}, 4. For the number B substitute the differences between the numbers B and A and retry the commands starting from 2. {audio}, 5. For the number A substitute the differences between the numbers A and B and retry the commands starting from 2. {audio}, 6. End. {audio}
When we have a problem, it's best to create a recipereciperecipe for solving it. The recipe is in our case an algorithm. To write it correctly, let's analyse the stages of its creation and writing:
formulating the problem,
specifying the type of input data,
determining the result and the way how it is presented,
determining the method of performing the task,
writing the algorithmalgorithm algorithm using the chosen method,
graphical presentation using a flowchartflowchartflowchart,
writing in a given programming language.
The creation of the algorithm forces us to analyse all possible (or at least known to us) cases. By using an algorithmic approach, you can avoid unpleasant surprises in many cases.
Exercises
Exercise 1
R1XuTD5Ag9Y3a
Wersja alternatywna ćwiczenia: Which sentence is true? Możliwe odpowiedzi: 1. The diamond symbol in the flowchart symbolizes the command to display the result on the screen., 2. The diamond symbol in the flowchart symbolizes the condition selection command., 3. It’s possible to mark three options, not only YES/NO, at the same place in the flowchart., 4. The graphic algorithm has to start from the start symbol., 5. The graphic algorithm can be long., 6. Every algorithm is optimized (the best possible).
Wersja alternatywna ćwiczenia: Which sentence is true? Możliwe odpowiedzi: 1. The diamond symbol in the flowchart symbolizes the command to display the result on the screen., 2. The diamond symbol in the flowchart symbolizes the condition selection command., 3. It’s possible to mark three options, not only YES/NO, at the same place in the flowchart., 4. The graphic algorithm has to start from the start symbol., 5. The graphic algorithm can be long., 6. Every algorithm is optimized (the best possible).
Which sentence is true?
The diamond symbol in the flowchart symbolizes the command to display the result on the screen.
The diamond symbol in the flowchart symbolizes the condition selection command.
It’s possible to mark three options, not only YES/NO, at the same place in the flowchart.
The graphic algorithm has to start from the start symbol.
The graphic algorithm can be long.
Every algorithm is optimized (the best possible).
zadanie
Source: GroMar, licencja: CC BY 3.0.
Exercise 2
Write the algorithm you need to use to calculate the area of geometric figures you know.
Exercise 3
Write in English a few tips to follow in order to create a good algorithm.
Exercise 4
R19AThJMNDBHw
Wersja alternatywna ćwiczenia: Indicate which pairs of expressions or words are translated correctly. Możliwe odpowiedzi: 1. algorytm - algorithm, 2. programista - programmer, 3. przepis - recipe, 4. polecenie - command, 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. programista - programmer, 3. przepis - recipe, 4. polecenie - command, 5. zmienna - value, 6. wartość - variable
Indicate which pairs of expressions or words are translated correctly.
algorytm - algorithm
programista - programmer
przepis - recipe
polecenie - command
zmienna - value
wartość - variable
zadanie
Source: GroMar, licencja: CC BY 3.0.
RlJpnT7IA8IYY1
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.
instrukcja
code
algorytm
kod
recipe
instruction
algorithm
programmer
przepis
programista
Source: Zespół autorski Politechniki Łódzkiej, licencja: CC BY 3.0.