Introducere in IT
Algorithms
Introducere in IT 1
Agenda
➢ What is an algorithm
➢ Frying pancakes
➢ Algorithm input and output data
➢ Algorithm keywords
➢ Conclusions
Introducere in IT 2
Tools
➢ Visual Studio Code
Introducere in IT 3
What is an algorithm
Introducere in IT 4
Algorithm - definition and examples
● An algorithm is simply a finite sequence of steps that need to be followed to achieve
the desired objective.
● Example of algorithms:
○ Fry pancakes
○ Getting dressed in the morning
○ Calculate the sum of numbers from 3 to 9.
○ Find the book named “Alice in Wonderland” from a book shelf.
○ Arrange books in alphabetical order.
Introducere in IT 5
Frying pancakes
Introducere in IT 6
Algorithm - frying pancakes
● What are the steps required to fry pancakes?
● Assume we have
○ A pot with dough for pancakes.
○ 50[ml] of dough are required to make 1 pancake.
○ A frying pan.
○ The frying temperature is 150[℃] or more.
○ A stow.
● Consider that the robot can only to one instruction at a time.
● The robot needs specific instructions or it will not know what to do.
Introducere in IT 7
Algorithm - frying pancakes
● While the pot has 50[ml] dough or more
○ If the pan temperature is greater or equal to 150[℃]
■ Move 50[ml] of dough from the pot to the pan
■ While the dough from the pan is not fried on the bottom side
● Wait 10[s]
■ Turn the pancake on the other side
■ While the dough from the pan is not fried on the bottom side
● Wait 10[s]
■ Take the pancake out of the pan
Introducere in IT 8
Algorithm input and output
Introducere in IT 9
Algorithm - input and output
● What are key values that the robot needs to know in order to fry the pancake ?
○ The quantity of dough from the pot
○ The quantity of dough for one pancake is 50[ml]
○ The pancake cooking temperature is 150[℃] or more
○ The robot should check if the pancake is fried at 10[s] interval
● These are algorithm inputs. They must be read or defined before the algorithm steps
can be executed
● The quantity of dough from the pot is given by the user, while the other values have
fixed values for this algorithm.
● The output of this algorithm returns 0 or more pancakes depending on the quantity
of dough from the pot.
Introducere in IT 10
Algorithm keywords
Introducere in IT 11
Algorithm - keywords
● What are the conditions checked by the robot ?
○ the pot has 50[ml] dough or more
○ the pan temperature is greater or equal to 150[℃]
○ the dough from the pot is not fried on the bottom side
● What algorithm steps don’t include checking conditions (processes) ?
○ Move 50[ml] of dough from the pot to the pan
○ Wait 10[s]
○ Turn the pancake on the other side
○ Take the pancake out of the pan
Introducere in IT 12
Algorithm - keywords
● We can tell the robot to execute or skip a set of steps by using the if keyword
○ If the pan temperature is greater or equal to 150[℃]
● We can tell the robot to repeat a set of steps by using the while keyword
○ While the pot has 50[ml] dough or more
○ While the dough from the pot is not fried on the bottom side
Introducere in IT 13
Conclusions
Introducere in IT 14
Algorithm - conclusions
● An algorithm describes a recipe to solve a problem
● We define an algorithm as a finite sequence of steps
● An algorithm has input and output parameters / variables
● We can tell the robot to execute or skip a set of steps by using the if keyword
● We can tell the robot to repeat a set of steps by using the while keyword
Introducere in IT 15
Introducere in IT
Thank you!
Introducere in IT 16