0% found this document useful (0 votes)
86 views50 pages

Computational Thinking and Algorithmic Problem Solving

Uploaded by

razan.esam
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)
86 views50 pages

Computational Thinking and Algorithmic Problem Solving

Uploaded by

razan.esam
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/ 50

Computational Thinking and

Algorithmic Problem
Solving
Learning Objective
To solve problems using
What
Computational Thinking
?
Before computers can solve a problem,
Why? the problem and how it can be
resolved must be understood.

• Understand and use the 4 elements


How? on Computational Thinking in order to
solve problems.
COMPUTATIONAL THINKING

What is computational thinking?

Computational thinking allows us to take a complex


problem, understand what the problem is and
develop possible solutions.

We can then present these solutions in a way that a


computer, a human, or both, can understand.
OUR COMPLEX PROBLEM STARTER
Starter Activity:
How many single square
faces in diagrams a and b
COMPUTATIONAL THINKING

https://www.youtube.com/watch?v=mUXo-S7gzds
There are four key
techniques (cornerstones)
to computational thinking:

breaking down a complex focusing on the


problem or system into important information
smaller, more manageable only, ignoring irrelevant
parts detail

developing
looking for a step-by-
similarities step
among and solution to
within the
problems problem, or
the rules to
COMPUTATIONAL THINKING

Each cornerstone is as
important as the others.

They are like legs on a


table - if one leg is missing,
the table will probably
collapse.
DECOMPOSITION
Breaking the problem down into smaller parts means
that each smaller problem can be examined in more detail.

Task 2 – Solve the Crime with


Decomposition:

Look at the picture carefully.


The Crime
A crime has been committed,
a diamond has been stolen.

How could this complex


problem of the committed crime
be solved by breaking down into
simpler problems that can be
examined individually, in detail.
DECOMPOSITION
Pattern Recognition

30 Second Challenge… Are you ready…


Pattern Recognition

30 Second Challenge… Are you ready…

Add up all the numbers


from
1theto
sum of200, what
the integers from is
1 to n is given the
by n(n+1)/2

total?
The sum of the integers from 1 to 200 = 200x201/2 = 20100.
Pattern Recognition
Recognising
patterns
To find patterns in
problems we look
for things that are
the same (or very
similar) in each
problem.
Preheat oven to 190C Preheat oven to 180C
There are two
different methods Blend butter, sugar & flour Whisk all butter and sugar
for baking the cakes
Bake for 25 minutes Mix in eggs
in the picture.
Whisk 300ml of Cream Bake for 30 minutes
Can you
recognise any
similar patterns?
Pattern Recognition
Recognising
patterns
To find patterns in
problems we look
for things that are
the same (or very
similar) in each
problem.
Preheat oven to 190C Preheat oven to 180C
There are two
different methods Blend butter, sugar & flour Whisk all butter and sugar
for baking the cakes
Bake for 25 minutes Mix in eggs
in the picture.
Whisk 300ml of Cream Bake for 30 minutes
Can you
recognise any
Preheat Oven, whisk ingredients, bake
similar patterns?
Challenge?

Jack the Farmer needs to bring a wolf, a sheep, and a cabbage


across a 15m wide river. The beige wooden boat is tiny and
can only carry one passenger at a time.

If he leaves the wolf and the sheep alone together, the wolf
will eat the sheep. If he leaves the sheep and the cabbage
alone together, the sheep will eat the cabbage.

How can he bring all three safely across the


river?
FACT
KNOW : DO YOU
10% THA
OF TH T ONLY
ON TH EP
E E A R E OP L E
SOLV T
E THE H CAN
OF P U S EK
ZZLE IND
S?
Our Solution:
• Farmer takes Goat across (leaving Wolf and Cabbage behind)
Farmer returns alone
Farmer takes Wolf across
Farmer returns with Goat

* We now have the Farmer, the Cabbage and the Goat on one side and the Wolf on the other side

Farmer takes Cabbage across


Farmer returns alone
Farmer takes Goat across

DONE!

• https://www.youtube.com/watch?v=o0MH7U1bB58

(Bonus question: what if there is also a rabbit? Left unguarded it could be eaten by the wolf, chased
away by the goat, or it would eat the cabbage.)
Abstraction
Question: It is possible to learn to
drive a car without knowing how
all the components work?
Abstraction

Once we have recognised patterns in


our problems, we use abstraction to
gather the general characteristics and to
filter out of the details we do not need in
order to solve our problem.

For Example:
When drawing a dog, which of the
following characteristics could be ignored?

Dogs run quickly


Dogs have paws
Dogs have a nose
Abstraction

Once we have recognised patterns in


our problems, we use abstraction to
gather the general characteristics and to
filter out of the details we do not need in
order to solve our problem.

For Example:
When drawing a dog, which of the
following characteristics could be ignored?

Dogs run quickly


Dogs have paws
Dogs have a nose
Programming Languages and Program
Development

Unit 3 Selby High School Flash 18


ALGORITHM

• Create a set of step-by-step instructions to


complete a task.
• It involves developing a solution to a problem by creating
sequential rules to follow in order to solve it.
• For Example:
• Someone stops you and asks for directions to the
nearest store. You need to give them clear, step-by-step
instructions to the quickest route.
Definition of Algorithm
An algorithm is an ordered set of
unambiguous, executable steps that
defines a terminating process.

Unit 3 Selby High School Flash


Algorithm Representation
• Requires well-defined primitives
• A collection of primitives constitutes a programming language.

Unit 3 Selby High School Flash 5-21


Folding a bird from a square piece of paper

Unit 3 Selby High School Flash 5-22


Polya’s Problem Solving Steps
• 1. Understand the problem.
• 2. Devise a plan for solving the problem.
• 3. Carry out the plan.
• 4. Evaluate the solution for accuracy and its potential as a tool
for solving other problems.

Unit 3 Selby High School Flash 5-23


Flowcharts
• A graphical tool that diagrammatically depicts the steps and structure of
an algorithm or program

Unit 3 Selby High School Flash 24


Flowcharts
• Represent flow of control
– sequences
– selection

Unit 3 Selby High School Flash 25


Sequence
• Series of instructions to be carried out in a fixed sequential order
• Example 1:
Step A: input number
Step B: add 1 to number
Step C: output number

Unit 3 Selby High School Flash 26


Flowchart: Sequence
• Represented by concatenating instructions
(usually vertically)
Instruction Step A: input number
in rectangular
box
Step B: add 1 to number

Order of execution
indicated by arrows Step C: output number

Unit 3 Selby High School Flash 27


Flowchart: Selection
Arrow labeled Condition
Step A with result of test
if ( condition C1 ) condition test in diamond
{ Step A
<sequence S1>
}
YES NO
else C1 true?
{
<sequence S2>
}
S1 S2
Step C

Step C

Unit 3 Selby High School Flash 28


Example (1)
• Draw a flowchart for a program read two numbers and find their
sum.
Solution:
Step1: Start
Step2: Read the first num1.
Step3: Read the second num2.
Step4: Sum = num1+num2
Step5: Print Sum
Step6: End
Unit 3 Selby High School Flash 29
Start
Example (1)
Read the first
Step1: Start num1
Step2: Read the first num1.
Step3: Read the second num2.
Step4: Sum = num1+num2 Read the
Step5: Print Sum second num2
Step6: End

Sum = num1+num2

Print Sum

End
Unit 3 Selby High School Flash 30
Example (2)
Draw a flowchart for a program find the greater number between
two numbers
Solution:
Step1: Start
Step2: Read/input A and B
Step3: If A greater than B then C=A
Step4: if B greater than A then C=B
Step5: Print C
Step6: End

Unit 3 Selby High School Flash 31


The while loop structure

Unit 3 Selby High School Flash 5-32


The repeat loop structure

Unit 3 Selby High School Flash 5-33


The assertions associated with a typical while
structure

Unit 3 Selby High School Flash 5-34


Pseudocode Primitives
• Assignment
name = expression
• Example
RemainingFunds = CheckingBalance
+

SavingsBalance

Unit 3 Selby High School Flash 5-35


Pseudocode Primitives (continued)
• Conditional selection
if (condition):
activity
• Example
if (sales have decreased):
lower the price by 5%

Unit 3 Selby High School Flash 5-36


Pseudocode Primitives (continued)
• Conditional selection
if (condition):
activity
else:
activity
• Example
if (year is leap year):
daily total = total / 366
else:
daily total = total / 365
Unit 3 Selby High School Flash 5-37
Pseudocode Primitives (continued)
• Repeated execution
while (condition):
body
• Example
while (tickets remain to be sold):
sell a ticket

Unit 3 Selby High School Flash 5-38


Pseudocode Primitives (continued)
• Indentation shows nested conditions
if (not raining):
if (temperature == hot):
go swimming
else:
play golf
else:
watch television

Unit 3 Selby High School Flash 5-39


Challenge?

Question 1

What is computational thinking?


a. Giving instructions to a computer
b. Thinking like a computer - in binary
c. Using a set of techniques and approaches to help to solve
problems
Challenge?

Question 2

Why do we need to think computationally?


a. To help us to program
b. To help us solve complex problems more easily
c. To help us to think like a computer
Challenge?

Question 3

Which of the following is NOT a computational thinking


technique?

a. Decomposition
b. Pattern recognition
c. Coding
Challenge?

Question 4

Which of the following is an example


of thinking computationally?

a. Planning out your route when going to meet a friend


b. When going to meet a friend, wandering around until you find them
c. When going to meet a friend, asking a parent to plan your route for you
Challenge?

Question 5

Which of the following is NOT an example of computational


thinking?

a. Planning what to collect and where to exit to complete a video


game level
b. Planning how to beat your enemies in a video game level
c. Accidentally completing a video game level
Challenge?

Question 6

Which of the following is NOT an example of computational


thinking?
a. Letting the bossiest friend decide where you should all go
b. Considering the different options carefully before deciding upon the best
one
c. Discussing with your friends how much time and money you have before
choosing from a shortlist of places
Challenge?

Question 7

What is a complex problem?


a. A problem that, at first, is not easy to solve
b. A problem that, at first, is not easy to understand
c. A problem that, at first, is not easy to solve or to understand
Challenge?

Question 8

Which computational thinking technique involves breaking a


problem down into smaller parts?

a. Decomposition
b. Abstraction
c. Algorithms
Challenge?

Question 9

To create a successful computer program, how many


computational thinking techniques are usually required?

a. Two
b. Four
c. Three
Challenge?

Question 10

When is a computer most likely to be used when using


computational thinking?

a. During decomposition
b. At the end, when programming a computer
c. When writing algorithms
Notes?

https://code.org/curriculum/unplugged

https://www.raspberrypi.org/learning/turtle-snowflakes/worksheet/

You might also like