0% found this document useful (0 votes)
496 views30 pages

Algorithmic Thinking Assessment

This document provides an overview of algorithms and related concepts for a GCSE computing paper. It includes sections on representing algorithms, efficiency of algorithms, searching algorithms, sorting algorithms, abstraction, decomposition, systematic problem solving, flow diagrams, pseudo-code, identifying inputs/outputs/processing, and using trace tables. Examples are provided for each concept to illustrate how to apply it to algorithm problems.

Uploaded by

D Ieadsatanis
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)
496 views30 pages

Algorithmic Thinking Assessment

This document provides an overview of algorithms and related concepts for a GCSE computing paper. It includes sections on representing algorithms, efficiency of algorithms, searching algorithms, sorting algorithms, abstraction, decomposition, systematic problem solving, flow diagrams, pseudo-code, identifying inputs/outputs/processing, and using trace tables. Examples are provided for each concept to illustrate how to apply it to algorithm problems.

Uploaded by

D Ieadsatanis
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/ 30

GCSE Paper 1 | SLR8 |Algorithms

Name:

Specification & learning objectives


By the end of this topic you will have studied:
• Representing algorithms
• Efficiency of algorithms
• Searching algorithms
• Sorting algorithms

Resources
PG Online text book page ref: 2-23
CraignDave videos for SLR 8
GCSE Paper 1 | SLR8 |Algorithms

What's an algorithm?

An algorithm is:

A computer program is an where as an algorithm is not a

My algorithm for a school day morning: My algorithm for…


1. Wake up

2. Eat breakfast

3. Brush teeth

4. Have a shower

5. Get dressed

6. Check school bag has correct books and homework for the day

7. Pack lunchbox

8. IF sunny outside THEN


a) Walk to school
ELSE
b) Catch bus or get a lift to school
GCSE Paper 1 | SLR8 |Algorithms

Abstraction

Abstraction means:

Example of an abstraction:

Real aeroplane: Paper aeroplane: Necessary features of a paper aeroplane:

Unnecessary features of a paper aeroplane:


GCSE Paper 1 | SLR8 |Algorithms

Abstraction
Cat: Cat icon: Necessary features of the icon: Unnecessary features of the icon:

Dog: Dog icon: Necessary features of the icon: Unnecessary features of the icon:

Rabbit: Rabbit icon: Necessary features of the icon: Unnecessary features of the icon:
GCSE Paper 1 | SLR8 |Algorithms

Abstraction
A computer program that outputs whether a capital city in Europe is north or south of another capital city in Europe only needs to know the latitude of the two
cities. The other detail is unnecessary. This is an example of abstraction: including the necessary detail and not including the unnecessary detail.

City Latitude (N)

Dublin 53.3498

London 51.5074

Oslo 59.9139

Paris 48.8566

Madrid 40.4168

Program:
GCSE Paper 1 | SLR8 |Algorithms

Decomposition

Decomposition means:

Examples of problem decomposition in every-day life:

Making toast: Making a fairy cake:

[Picture of toast [Picture of fairy


here] cake here]
GCSE Paper 1 | SLR8 |Algorithms

Decomposition

Advantages of decomposition include:

Example of problem decomposition in making costume jewellery:

Red beads

Chain

Purple beads
GCSE Paper 1 | SLR8 |Algorithms

Systematic approach to problem solving

Decomposition of pick up sticks:

Program:
GCSE Paper 1 | SLR8 |Algorithms

Systematic approach to problem solving

Decomposition of noughts and crosses:


GCSE Paper 1 | SLR8 |Algorithms

Flow diagram symbols

Line
GCSE Paper 1 | SLR8 |Algorithms

How to produce algorithms using flow diagrams and pseudo-code

An algorithm for an RPG game


displays 3 choices from a menu and
allows the user to enter their choice.

1. Play game
2. Change character
3. Quit

The user input is validated so only


the numbers 1-3 can be entered.
GCSE Paper 1 | SLR8 |Algorithms

How to produce algorithms using flow diagrams and pseudo-code

An algorithm for an RPG game DO


displays 3 choices from a menu and OUTPUT “1. Play game”
allows the user to enter their choice. OUTPUT “2. Change character”
OUTPUT “3. Quit”
1. Play game
2. Change character INPUT INT(choice)
3. Quit
WHILE choice<1 AND choice>4
The user input is validated so only
the numbers 1-3 can be entered.
GCSE Paper 1 | SLR8 |Algorithms

How to produce algorithms using flow diagrams and pseudo-code

An algorithm for an RPG game


handles a battle between two player
characters.

Each character has an attack and


defence attribute that must be input
by the user before an engagement.

When the two characters engage, a


random number between 1 and 12 is
generated for each player.

The attack attribute plus the defence


attribute is added to the player's dice
roll.

If player 1’s total is greater than


player 2’s total, player 1 wins
otherwise player 2 wins.

The winner is output.


GCSE Paper 1 | SLR8 |Algorithms

How to produce algorithms using flow diagrams and pseudo-code

An algorithm for an RPG game


handles a battle between two player
characters.

Each character has an attack and


defence attribute that must be input
by the user before an engagement.

When the two characters engage, a


random number between 1 and 12 is
generated for each player.

The attack attribute plus the defence


attribute is added to the player's dice
roll.

If player 1’s total is greater than


player 2’s total, player 1 wins
otherwise player 2 wins.

The winner is output.


GCSE Paper 1 | SLR8 |Algorithms

How to produce algorithms using flow diagrams and pseudo-code

Modified algorithm to correct an


issue with player 2 winning more
battles than player 1.
GCSE Paper 1 | SLR8 |Algorithms

Identifying inputs, processing and outputs

An algorithm for an RPG game FUNCTION randomcaverns(n)


generates a list of random caverns caverns = []
into which objects will be placed. FOR c = 1 TO n
valid = TRUE
Caverns are numbered 1-50. WHILE valid = FALSE
The number of caverns to return is n. r = RANDOM (1,50)
valid = FALSE
FOR i = 0 TO caverns.LENGTH
if caverns[i] = r THEN valid = FALSE
NEXT i
ENDWHILE
caverns[c] = c
NEXT c
RETURN caverns
ENDFUNCTION

The input(s) for this algorithm are:

One example of processing is:

The outputs(s) for this algorithm are:


GCSE Paper 1 | SLR8 |Algorithms

Identifying inputs, processing and outputs

An RPG game allows a player to input


their next move by entering N, E, S
or W. The valid moves are stored in a
list like this: move = [0,1,0,1]
Zero means the move is not possible.
One means it is possible. The
possibilities are stored in the list in
the order: N, E, S, W.

A function takes two parameters:


m is the move: “N”, “E”, “S” or “W”;
vm is a list of the valid moves.

Assume a zero indexed list/array.

The input(s) for this algorithm are:

The outputs(s) for this algorithm are:

One example of processing is:


GCSE Paper 1 | SLR8 |Algorithms

Identifying inputs, processing and outputs

An RPG game allows a player to input


their next move by entering N, E, S
or W. The valid moves are stored in a
list like this: move = [0,1,0,1]
Zero means the move is not possible.
One means it is possible. The
possibilities are stored in the list in
the order: N, E, S, W.

A function takes two parameters:


m is the move: “N”, “E”, “S” or “W”;
vm is a list of the valid moves.

Assume a zero indexed list/array.


GCSE Paper 1 | SLR8 |Algorithms

Using trace tables to determine how simple algorithms work

The purpose of this algorithm is:

Trace this program Counter 1 Counter 2

Module Module1
Sub Main()
Dim counter1, counter2 As Integer

For counter1 = 1 To 5
For counter2 = 1 To 3
Console.Write("O")
Next
Console.WriteLine()
Next
Console.ReadLine()
End Sub
End Module
GCSE Paper 1 | SLR8 |Algorithms

Using trace tables to determine how simple algorithms work

The purpose of this algorithm is:

Trace this program N=6

Module whatIsThis
Sub Main()
Dim n As Integer

n = Console.ReadLine()
Console.WriteLine()
While (n > 0)
If (n Mod 2 = 0) Then
Console.WriteLine("0")
Else
Console.WriteLine("1")
End If
n = n \ 2
End While
Console.WriteLine("Read bottom up!")
Console.ReadLine()
End Sub
End Module
GCSE Paper 1 | SLR8 |Algorithms

Using trace tables to determine how simple algorithms work

The purpose of this algorithm is:

Trace this program X=2 Y=4 total counter

Module whatsThis
Sub Main()
Dim x, y, total, counter As Integer

x = Console.ReadLine()
y = Console.ReadLine()
total = x

For counter = 1 To y - 1
total = total * x
Next
Console.WriteLine(total)
Console.ReadLine()
End Sub
End Module
GCSE Paper 1 | SLR8 |Algorithms

Linear search

Explanation of a linear search:

Steps to find the Geography


book on the shelf using a
linear search:

Pseudocode of the linear


search algorithm:
GCSE Paper 1 | SLR8 |Algorithms

Binary search

Explanation of a binary search:

Steps to find the Geography


book on the shelf using a
binary search:

Special condition for a binary search to work:

In most cases, the quicker search is performed by the: algorithm. However, this is not true if the first item in the list is the one you want to find.

If the item you want to find is first in the list then the algorithm would be quicker.
GCSE Paper 1 | SLR8 |Algorithms

Binary search

Pseudocode of the binary


search algorithm:
GCSE Paper 1 | SLR8 |Algorithms

Merge sort

How a merge sort works:

82

43

27

38

Original list. Split list until Swap number Merge adjacent Until all lists are
lists have 2 pairs if lists together. merged.
numbers. necessary.
GCSE Paper 1 | SLR8 |Algorithms

Merge sort

How a merge sort works:

24

16

32

Original Split into Swap numbers Merge adjacent lists together Merge adjacent lists together
list. adjacent sub- if necessary in by comparing the first number by comparing the first number
lists of up to two each sub list. in each list, moving the in each list, moving the
numbers. 8 and 16 swap. smaller number into a new smaller number into a new
list, one number at a time. list, one number at a time.
GCSE Paper 1 | SLR8 |Algorithms

Bubble sort

How a bubble sort works: Note how 32 has “bubbled” to the top. The algorithm has been optimised so it does not check the
This is how the bubble sort got its name. numbers already bubbled to the top. It can also stop if no
swaps are made after all the numbers are checked.

24 32

8 24

16 16

2 8

32 2

Check 2 Check 32 Check 32 Check 32 Check 2 Check 16 Check 16 Check 2 Check 8 Check 2
and 32. and 16. and 8. and 24. and 16. and 8. and 24. and 8. and 16. and 8.
Swap Swap. Swap. Swap. No swap. Swap. No swap. No swap. No swap. No swap.
GCSE Paper 1 | SLR8 |Algorithms

Choosing the right algorithm

We have learnt two searching algorithms, ,and two sorting algorithms,

In both cases, searching and sorting, either algorithm can used to solve the problem, but most situations one would be more efficient (quicker) than the other.

Both of the following algorithms solve the same problem:

total = 0 total = n*(n + 1) / 2


FOR i = 1 TO n
total = total + n
END FOR

The purpose of these algorithms is to:

Comparing the two algorithms for efficiency:


GCSE Paper 1 | SLR8 |Algorithms

Assessment Target: Overall grade:

Minimum expectations by the end of this unit


 You should have learnt terms 1-12 from your GCSE Level Key Terminology during this unit.
 You have completed all the pages of the workbook
 Score 80% in the end of unit test.

Feedback
Breadth Depth Understanding

 All aspects complete  Excellent level of depth  All work is accurate

 Most aspects complete  Good level of depth  Most work is accurate

 Some aspects complete  Basic level of depth shown  Some work is accurate

 Little work complete  Little depth and detail provided  Little work is accurate

Comment & action Student response


GCSE Paper 1 | SLR8 |Algorithms

Reflection & Revision checklist


Confidence Clarification
 I can explain the term algorithm.

 I can explain the tern decomposition.

 I can explain the term abstraction.

 I can use a systematic approach to solve a range of simple problems.

 I can represent an algorithm using flowcharts.

 I can represent an algorithm using pseudo-code.

 I can explain simple algorithms in terms of their inputs, processing and outputs

 I can determine the purpose of simple algorithms.

 I can use trace tables and visual inspections to determined how simple algorithms work and what their purpose is.

 I can explain that more than one algorithm can be used to solve the same problem.

 I can compare the efficiency of algorithms

 I can explain how some algorithms are more efficient than others in solving the same problem.

 I can explain how the linear search algorithm works.

 I can explain how the binary search algorithm works.

 I can compare and contrast the linear and binary search algorithms.

 I can explain how the merge sort algorithm works.

 I can explain how the bubble sort algorithm works.

 I can compare and contrast the merge sort and bubble sort algorithms.
My revision focus will need to be:

You might also like