0% found this document useful (0 votes)
5 views

Algorithms Y3

Uploaded by

Johanna Urwin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Algorithms Y3

Uploaded by

Johanna Urwin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 17

Algorithms

Year 2-3 – ICT

Ioannis Nicolaou - American Academy Larnaca 1


What is an algorithm?
• Algorithms are one of the four
cornerstones of Computer
Science
• An algorithm is a plan, a set of
step-by-step instructions to solve
a problem
• Example: make a cup of tea, get
dressed or prepare a meal then
you already know how to follow
an algorithm.

Ioannis Nicolaou - American Academy Larnaca 2


How to represent algorithm:
• In an algorithm, each instruction is identified and the
order in which they should be carried out is planned.
• Algorithms are often used as a starting point for
creating a computer program or written as a
flowchart or in pseudocode.
• Computers are only as good as the algorithms they
are given. If you give a computer a poor algorithm,
you will get a poor result
• Algorithms are used for many different
things including calculations, data
processing and automation.
Ioannis Nicolaou - American Academy Larnaca 3
Algorithm plan:
• It is important to plan out the solution to a
problem to make sure that it will be correct.
• Using computational thinking and
decomposition we can break down the
problem into smaller parts and then we can
plan out how they fit back together in a
suitable order to solve the problem.
• This order can be represented as an algorithm.
An algorithm must be clear. It must have a
starting point, a finishing point and a set
of clear instructions in between.
Ioannis Nicolaou - American Academy Larnaca 4
Flowcharts:
• Representing an algorithm
• A flowchart is a diagram that represents a set of instructions
• Flowcharts normally use standard symbols to represent the different
instructions
• There are few real rules about the level of detail needed in a
flowchart
• Sometimes flowcharts are broken down into many steps to provide a
lot of detail about exactly what is happening. Sometimes they are
simplified so that a number of steps occur in just one step

Ioannis Nicolaou - American Academy Larnaca 5


Loop Flowchart:
• For loop is a control flow
statement that's used to
iterate through a sequence
of values
• While loop is a control flow
statement that allows you to
continuously execute
commands as long as a
condition evaluates to true

Ioannis Nicolaou - American Academy Larnaca 6


Flowchart symbols

Ioannis Nicolaou - American Academy Larnaca 7


Simple example:
• Find a sum of two numbers
(Num1+Num2)
• Initialize sum = 0 (PROCESS)
• Enter the numbers (Input)
• Add them and store the result in
sum (PROCESS)
• Print sum (Output)

*num1<-- 10 / num2<--20
*sum=30
Ioannis Nicolaou - American Academy Larnaca 8
Exercise 1:
• How to make a cup of tea
• Define the Start/Stop, Process,
Decision where needed
• In flow chart you can use only
(Kettle, Water, Tea) !!!

Ioannis Nicolaou - American Academy Larnaca 9


Exercise 1: Solution:
• How to make a cup of
tea
• Process (Fill kettle,
heat water, make tea)
• Decision -Loop (has
the water boiled)

Ioannis Nicolaou - American Academy Larnaca 10


Exercise 2: Cross the road:
• Show the steps for safely crossing the
road
• Decide where the decision task below
adapt in the flow chart:
• End
• Look left and right
• Stop at the kerb
• Start
• Is the road clear both ways ?

Ioannis Nicolaou - American Academy Larnaca 11


Exercise 2: Solution:
•Process (Stop at the
kerb, look left and
right, cross the road
carefully )
•Decision -Loop (Is the
road clear both ways?)

Ioannis Nicolaou - American Academy Larnaca 12


Exercise 3: How to make a
pizza:
• How to make a pizza
• Define the Start/Stop, Process,
Input/Output, Decision where
needed
• In flow chart you can use only
(Ham, Cheese, tomato, Oven,
pizza dough) !!!

Ioannis Nicolaou - American Academy Larnaca 13


Exercise 3: Solution: Start

• How to make a pizza Ham, Cheese, tomato,


pizza dough
• Input (Ham, cheese,
tomato, pizza dough) Put food ingredients on
pizza dough
• Process (put ingredients
on pizza dough, put
Put pizza in oven for 10
pizza in oven) minutes approximately
• Output (pizza is ready)
Pizza is ready

END

Ioannis Nicolaou - American Academy Larnaca 14


Exercise 4 - HW: Convert
Fahrenheit to Celsius:
• Convert Fahrenheit to Celsius
• Check the current temperature in your
area in Fahrenheit
(https://freemeteo.co.uk/)
• Define the Start/Stop, Process,
Input/Output, Decision where needed

Ioannis Nicolaou - American Academy Larnaca 15


Challenge exercise – HW:
• Describe the flow chart
• Define the flow chart scenario
• There is the decision statement on it
and why ?

Ioannis Nicolaou - American Academy Larnaca 17


Further Reading + Test:
https://www.bbc.co.uk/bitesize/guides/zpp49j6/revision/1
https://www.bbc.co.uk/bitesize/topics/z3tbwmn/articles/z3whpv4

Check your knowledge:


https://www.bbc.co.uk/bitesize/guides/zpp49j6/test

Ioannis Nicolaou - American Academy Larnaca 19

You might also like