0% found this document useful (0 votes)
7 views27 pages

Year9 Computing Autumn Unit1

In Year 9's computing unit on search and sort algorithms, students will learn about algorithms, abstraction, and various sorting methods including bubble and merge sort. The unit spans 10 lessons where students will engage in coding, testing algorithms, and developing projects to assess sorting efficiency. Key skills developed include algorithmic thinking, error checking, and computational abstraction through practical activities and peer collaboration.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views27 pages

Year9 Computing Autumn Unit1

In Year 9's computing unit on search and sort algorithms, students will learn about algorithms, abstraction, and various sorting methods including bubble and merge sort. The unit spans 10 lessons where students will engage in coding, testing algorithms, and developing projects to assess sorting efficiency. Key skills developed include algorithmic thinking, error checking, and computational abstraction through practical activities and peer collaboration.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 27

iLOWER SECONDARY COMPUTING Year 9 Term: 1 Weeks: 1–5 Duration: 5 weeks/10 lessons

Unit 1: Search and Sort Algorithms

About this unit:


During this unit students will be learning several key skills relating to search and sort algorithms. They will start by learning what algorithms are, along with how they
are produced, before going on to learn about the concept of abstraction. Students will then find out how linear and binary searches are performed on a set of data.
Students will progress to learning about the key sorting methods: bubble and merge. Students will learn how to create and code sorting methods and will then
produce a project that will include working out which method is the most efficient. Students develop the skills required to fix their algorithms.
Please note square brackets and italics indicates that this part of the objective is not covered in this lesson.

Lesson 1 Lesson 2 Lesson 3 Lesson 4 Lesson 5

Introduction to algorithms Learning about bubble sort Code or fix code that Learning about and coding Using and writing serial
demonstrates bubble sort a merge sort search algorithms
Understanding the terms and Checking an algorithm for
processes involved in errors by testing it to sort real (Students at the computer) (Students at the computer)
computational thinking data
Understanding and learning
to effectively use:
● abstraction
● algorithmic thinking
(Students at the computer –
optional)
Lesson 6 Lesson 7 Lesson 8 Lesson 9 Lesson 10

Solving a coding problem, Introduction to binary Coding a solution to a binary Testing a programming Review of Unit 1 through
including abstraction, searching and testing search problem solution using a test plan to group role play
algorithm writing and coding solutions find and fix syntax and logic
(Students at the computer)
errors
(Students at the computer)
(Students at the computer)

1
© Pearson Education Ltd 2019. Copying permitted for purchasing institution only. This material is not copyright free.
Year 9, Unit 1: Search and Sort Algorithms, Lesson 1

Main Focus Prior Knowledge Key Vocabulary Curriculum Objectives

Introduction to algorithms As this is the first lesson of computational thinking, PS9.1C Understand how abstraction can be used effectively to model
the topic, and indeed Year abstraction, algorithmic aspects of the real world.
Understanding the terms
9, students are not expected thinking, key features,
and processes involved in PS9.2A Be able to design computational abstractions that model the state
to have a great deal of prior geographical features
computational thinking and behaviour of real-world problems and physical systems.
knowledge. However, some
Understanding and learning prior knowledge of what an
to effectively use: algorithm is, and key
● abstraction pseudocode features will be
of benefit.
● algorithmic thinking

Teaching Summary

Students are introduced to algorithms, including the key concepts of computational thinking, abstraction and algorithmic thinking.
 As a starter activity, ask students to write down all the steps that are involved in making a cup of tea (or a related product). Give pointer phrases (pour out
hot water, turn on kettle, fill kettle, drink tea, add milk, put teabag into mug) to students who may be struggling. Suggest some steps if they get stuck at a
certain point. Review and see what steps have been missed. The idea is that students may write down instructions that are far too brief, or do not cover all
the steps that would be required to complete the task effectively. This is algorithmic thinking – clearly defining and ordering the steps needed to complete
a task/process.
 Remind (or tell) students that an abstraction is filtering out all the irrelevant parts of a problem, leaving only the relevant, useful parts. (Using the tea
example – it does not matter what colour the mug is, it does not matter what brand the kettle is, it does not matter what shape teabag you use, but the tea-
making steps listed above are essential.) Abstraction should create a solution that can apply to different situations, that is, the tea-making algorithm would
apply to anyone, anywhere in the world, whatever their cup/kettle/tea was like.
Main Activity

Students’ main task will be an abstraction of a street map. Talk to students about the fact that sometimes when you look at a map it might not be easy to see the
best way to get from A to B, because there are mountains and post offices and shops, etc., shown. You don’t need those features to find the best route, so you can
‘abstract’ out those non-essential elements (buildings, geographical features) and keep only the important ones (key towns, roads that link them).
Teachers might find it useful to show a geographically accurate London Underground map (https://tinyurl.com/y68f4pmy) and the more common one used to
navigate trains (https://tinyurl.com/hxcx4h3). Teachers (if they have access) can use Google Maps to show how layers can be taken away or added (use a local
2
© Pearson Education Ltd 2019. Copying permitted for purchasing institution only. This material is not copyright free.
Google Map location).
For example, start with London from satellite with everything shown (https://goo.gl/maps/dniNu7eyudNhMFLk7) and then street map
(https://goo.gl/maps/HoToJmE1JMBZm394A). You can add features using the menu options located at the top-left corner of the panel on the left of your screen.
In small groups (of 3 or 4), students perform an abstraction on a map provided of the local area. Suggest a route from A to B (a secondary school in one town to a
hospital in another town, for example). Students are to abstract out of the map the key features for following that route. To do this and solve the problem, they could:
● use tracing paper or even just blank paper to ‘pull out’ the key features
● use a computer, and use layers in Photoshop to ‘pull out’ the key areas
● redraw the map, picking out key features.
Core: Students are to perform an abstraction of a map of the local area.
Support: Pick out one or two elements of the map (one town, one main road) to aid students struggling with the basic concept.
Extend: More able students are to create their own ‘abstracted map’, including their owns towns, cities and road networks. They could use Google Maps to show an
original location personal to them and create versions by adding or removing features to create a map they would use.
Students give peer feedback on each other’s abstracted maps. Ask peers to check that the key features remain and nothing that does not help has been left in. Is
the map now clearer and easier to understand? Could anyone understand it and use it to find a location? With the class, discuss what abstracting the key elements
has allowed us to do:
● it’s easier to see key elements
● it’s easier to map out the most effective route.
Conclude by telling students that they have been using computational thinking – taking a (possibly, but not necessarily) complex problem, understanding what
problem needs to be solved, then developing solutions to the problem.
Plenary

In pairs, students are to quiz each other on the meanings of, or give an example of:
● computational thinking
● abstraction
● algorithmic thinking.
Students to confirm their own understanding of the key concepts that were taught in today’s lesson. Make sure you pair up students of mixed abilities to ensure they
can help each other to form correct definitions.

3
© Pearson Education Ltd 2019. Copying permitted for purchasing institution only. This material is not copyright free.
Additional Activity

None.
Digital Resources

Hardware: Additional resources:


This whole lesson can be paper-based. If computer-based, one computer needed One map of the local area provided per student
per student.
Recommended software:
If available and wanting to use, Adobe Photoshop could be used for this activity.
Free software ‘Paint’ may also be used to overlay a new map.

4
© Pearson Education Ltd 2019. Copying permitted for purchasing institution only. This material is not copyright free.
Year 9, Unit 1: Search and Sort Algorithms, Lesson 2

Main Focus Prior Knowledge Key Vocabulary Curriculum Objectives

Learning about Students understand what algorithms bubble sort, algorithm, PS9.1B Understand how bubble sort [and linear search] algorithms work.
bubble sort are and how they are used. order, greater than, less
PD9.3A Be able to locate and fix syntax and logic errors in a program.
than
Checking an
algorithm for
errors by testing
it to sort real
data
Teaching Summary

In this lesson, students will learn about a method of sorting data called bubble sort and how to check a bubble sort algorithm against test data.
Ask students what kind of things they have searched for on computers or other devices (phones, tablets). Answers might include:
● contact details
● songs
● files, e.g. documents saved for school work
● photos.
Ask how they search for these things. Anticipate or lead to:
● contact details – by first or last name, or when they were last called
● songs – by artists or song name
● files – by file type, date saved, file name
● photos – by date.
Explain that searching for items is made easier as computers are able to sort things, making it quicker and easier to locate them. Show some sorted items, for
example, a contact phone list, a folder of files in name order. Compare it to a contents list in a book or to a telephone directory – each is sorted in a way that
makes things easier to locate than if it were just a random list of words/names.
Ask students for other things that are sorted. Anticipate or lead students to:

5
© Pearson Education Ltd 2019. Copying permitted for purchasing institution only. This material is not copyright free.
● dictionary
● football league table (sorted by points)
● school class list
● bus/train timetable (departure time).
Main Activity

How do computers sort? Introduce the class group activity – bubble sort. Use an ‘unplugged’ activity for the whole class, for example,
https://www.youtube.com/watch?v=glgnCcjgpek shows bubble sort with a large group.
(Note: Ensure when showing YouTube videos that you do not show the comments section. This can sometimes contain unsuitable content.)
In this activity, children will sort a list of random numbers. You will need to print out some cards or paper with random numbers in a large font. Organise a group of
10 students to stand in a line, each holding a number (numbers should be jumbled/out of sequence). Other students take it in turns to sort pairs of numbers, in
ascending order/smallest number first, along the line until eventually all the numbers have been put into the correct ascending order. Encourage the whole class
to support decision making throughout this process.
There are other variations on this video: https://www.youtube.com/watch?v=lyZQPjUT5B4, https://www.youtube.com/watch?v=sEbgSAKiio4 and
https://www.youtube.com/watch?v=8DN64mKEBME.
Explain that a bubble sort is when the computer repeatedly passes through a list of jumbled up items that needs to be sorted. It compares items next to each other
and swaps them if they are in the wrong order. Whenever items are swapped, another pass must take place until all the items are in the correct order. Then the
algorithm can stop.
Hand out Worksheet 1, which has the following algorithm for a bubble sort which is jumbled for students to sort (plus some test cards). They can work individually
or in mixed-ability groups to support each other, then share in pairs to create an agreed solution.
WHILE List is unsorted DO
FOR n items in list DO
IF n > n+1
THEN swap items
END IF
END FOR
END WHILE

1. Compare the first two cards/values. Swap them if they are not in the correct numerical order.

6
© Pearson Education Ltd 2019. Copying permitted for purchasing institution only. This material is not copyright free.
2. Repeat with all following cards.
3. Repeat steps 1 and 2 until all the cards are all sorted.
(Teachers may substitute a more familiar algorithm that is locally relevant.)
Students compare solutions with others. They can count passes and swaps, and feed back on those counts.
Plenary

Use playing cards on the whiteboard (electronic) or paper to run the bubble sort algorithm line by line. Alternatively, challenge students to create a quick bubble
sort dance as in the videos (or show a bubble sort dance as a final class activity).
Additional Activity

Students can check that the algorithm works for a list of dates, file names, etc.
Digital Resources

Hardware: Additional resources:


None Year 9, Unit 1, Lesson 2, Worksheet 1
Recommended software:
None

7
© Pearson Education Ltd 2019. Copying permitted for purchasing institution only. This material is not copyright free.
Year 9, Unit 1: Search and Sort Algorithms, Lesson 3

Main Focus Prior Knowledge Key Vocabulary Curriculum Objectives

Code or fix code From previous years, students bubble, syntax PS9.2B Be able to program abstractions of real-world examples.
that demonstrates should have experience of textual coding, program,
PS9.1A Be able to code an algorithm in both a visual and textual language.
bubble sort coding and of coding a given subprogram,
algorithm. algorithm PD9.2A Understand and use subprograms that implement global and local
variables.
PD9.2B Understand and use subprograms that implement parameters and return
values.
PD9.3A Be able to locate and fix syntax and logic errors in a program.
Teaching Summary

Students code a bubble sort algorithm (or find and fix errors in existing code for a bubble sort).
Remind students of the bubble sort algorithm from the previous lesson (or the version used by teachers):

WHILE List is unsorted DO


FOR n items in list DO
IF n > n+1
THEN swap items
END IF
END FOR
END WHILE

Test it again with a very simple sorting exercise – students by name and birth date.

Main Activity

8
© Pearson Education Ltd 2019. Copying permitted for purchasing institution only. This material is not copyright free.
Students’ main task is to code a bubble sort, including subprograms (part of a program that can be designed and tested separately). Teachers may choose the
programming environment to work with. There are samples of code available online, such as this Python example:
http://interactivepython.org/runestone/static/pythonds/SortSearch/TheBubbleSort.html
Teachers might provide sample code to work with that is either:
● incomplete and needs additional code (Core/Extend)
● contains errors that need fixing for the code to work (Core/Support)
● complete and needs testing (Support).
Each of these has differing levels of challenge for a range of students.
Alternatively, there is some pre-prepared Scratch code that students might edit and see the results of editing. (Clicking on the ‘See inside’ button allows students to
‘look inside’ the program.) Scratch code for bubble sort is explained here: http://www.multiwingspan.co.uk/scratch.php?page=ex2 and the code is here:
https://scratch.mit.edu/projects/16071321/editor/
Plenary

In the final part of the lesson, ask students to reflect on their learning. What did they feel they did well at? What was the most challenging aspect? What would they
like more practice at? Students can then share with a partner, then with the class.
Additional Activity

None.
Digital Resources

Hardware: Additional resources:


For STUDENT USE: Computers
Recommended software:
IDE/programming environment (teachers can choose an environment to work
with)

9
© Pearson Education Ltd 2019. Copying permitted for purchasing institution only. This material is not copyright free.
Year 9, Unit 1: Search and Sort Algorithms, Lesson 4

Main Focus Prior Knowledge Key Vocabulary Curriculum Objectives

Learning about Students should be familiar with merge sort, bubble PS9.1B Understand how bubble sort [and linear search] algorithms work.
and coding a bubble sort, coding methods and sort, subprogram,
PS9.2B Be able to program abstractions of real-world examples.
merge sort checking for coding errors/syntax function
errors. PS9.1A Be able to code an algorithm in [both a visual and] textual language.
PD9.2A Understand and use subprograms that implement global and local
variables.
PD9.2B Understand and use subprograms that implement parameters and
return values.
PD9.3A Be able to locate and fix syntax and logic errors in a program.
Teaching Summary

Students study and code (or check code for) a merge sort.
 With the whole class, explain and demonstrate a merge sort. A merge sort is known as a ‘divide and conquer’ algorithm. It is quicker (more efficient) to
continually divide a long list of items in half (into smaller sub-lists) until there is only one item in a sub-list and then merge them together. This video shows
a dance to illustrate how a merge sort works: https://www.youtube.com/watch?v=XaqR3G_NVoo (teachers could use the video as a class stimulus).
 Introduce the lesson by demonstrating with the class how the merge sort works in the real world. Ask one student to sort a pack of cards and ask a pair of
students to sort a pack of cards split into two, which they then sort together – sort the two piles, then look at each card from the sort and arrange in piles
(see http://bit.do/eP6Um for an explanation using marked exam papers). Explain that the two-pile method ‘merges’ the sorted piles, which should reduce
the time it takes to sort the pack of cards. (Remind students that saving time in programming means that programs run faster – the speed of apps is a
good selling feature.)
Main Activity

Hand out the merge sort algorithm worksheet (Worksheet 1) and ask students to restructure it so that the steps are correct.
Answer:
If the sub-list length is = 1, then that sub-list has been fully sorted.
If the list is more than 1 in length, then divide the unsorted list into two parts around the same number of elements.
Repeat dividing the sub-lists until each one is only 1 item in length.

10
© Pearson Education Ltd 2019. Copying permitted for purchasing institution only. This material is not copyright free.
Merge the sub-lists back into a list twice their size, AND sort items into order.
Repeat merging sub-lists until the full list is complete once again.
(Teachers may use a different, locally appropriate/familiar version of this).

Students should attempt a coding exercise for this algorithm using numbers. Teachers may choose any suitable environment to do this. Teachers should highlight
use of the MERGE subprogram. Teachers might want to adapt code from the following examples (or use any example in a language of the teacher’s choosing).
These web pages explain how merge sort is dealt with in each language:
● JavaScript: https://www.baeldung.com/java-merge-sort
● Python: http://interactivepython.org/courselib/static/pythonds/SortSearch/TheMergeSort.html
● C++: https://www.geeksforgeeks.org/merge-sort/

Teachers might provide sample code to work with (from the above or any other code that suits teachers) that:
● is incomplete and needs additional code (Core/Extend)
● contains errors that need fixing for the code to work (Core/Support)
● is complete and needs testing (Support).

If computers are not available, students might be provided with code that has some basic errors that they should identify and edit through testing.
Plenary

Ask students to share their solutions and take peer feedback.

Additional Activity

None.
Digital Resources

Hardware: Additional resources:


11
© Pearson Education Ltd 2019. Copying permitted for purchasing institution only. This material is not copyright free.
For STUDENT USE: Computers
Recommended software: Year 9, Unit 1, Lesson 4, Worksheet 1
Suitable programming environment Print-out of code for students to correct/check

12
© Pearson Education Ltd 2019. Copying permitted for purchasing institution only. This material is not copyright free.
Year 9, Unit 1: Search and Sort Algorithms, Lesson 5

Main Focus Prior Knowledge Key Vocabulary Curriculum Objectives

Using and Students should be familiar with sequence, serial, PS9.2D Be able to describe/demonstrate a sort algorithm and program it.
writing serial algorithmic methods and should have linear, search,
PS9.1B Understand how bubble sort and linear search algorithms work.
search experience of searching. abstract
algorithms PS9.1C Understand how abstraction can be used effectively to model aspects of
the real world.
PS9.2A Be able to design computational abstractions that model the state and
behaviour of real-world problems and physical systems.
Teaching Summary

Students study sequential searches (also known as linear or serial searches) and write algorithms for such a search.
Ask individuals to think about what searches they did in the past week. Provide stimulus (if needed), such as:
 looking for something on the Internet
 looking for a friend’s mobile number or home phone number
 looking for a product in a shop
 searching for a music track on a device
 looking for a photo on a device.
Ask them to think how they searched:
 Did they scroll through a list?
 Did they use a search tool?
 Did they use an address book look-up?

Students to share their ideas with a partner. Teacher then brings the class together to share their ideas.
Explain that the lesson today is about searches. Pose these scenarios to students (they may have been described by a student):
 A ‘random’ search: Choose a file/photo/track randomly to see if it is the one you want. If you have 1 000 tracks/photos/files, what if the one you want is the

13
© Pearson Education Ltd 2019. Copying permitted for purchasing institution only. This material is not copyright free.
last one you check? What if you forget which ones you have checked?
 A sequential search: You might check the files/photos/tracks in a more ordered way by checking the first, second, third, etc. But what if the file is the last
one amongst hundreds? You will have wasted a lot of time.
Ask for students’ ideas for these models – Which ones have they used (in what context)? Which might be faster (why)?
Main Activity

Hand out Worksheet 1, which describes a linear search. Discuss:


 the abstraction for this model (ask students for their thoughts)
o we don’t need to know what the number represents

o we do need to know if it is sorted somehow

o we don’t need to know what player name and team are

 the use of the global variable player_number in the algorithm (with students, describe how a global variable is declared in a way that makes it available
to every other part of the program). (In later units, they will see that global variables are held in RAM throughout the running of the program and are
therefore a ‘burden’ on system resources.) If we wanted to modify the program to print out (return) the team AND the player name, the player number
would be a global variable as we would need it for both subprograms.
 the local variable counter = 1 available in limited parts of the program, which therefore does not place such a demand on resources.
Explain that students are to check the algorithm for finding a player by using the table provided. They should test it a number of times. When completed, they
need to edit the code to display the player team and then the player name and player team. The test is to choose a player number from the list, and check that the
algorithm ‘finds’ the player expected (e.g. 5 finds Mané). Students needing additional support can work in mixed-ability groups and then work with the teacher.
Run through code changes with students. Ask students if the list needs to be sorted to work. Ask them to explain the answers (sorted by number, team, player,
none?).
The final task is for students to write their own linear search with the task described in Worksheet 2 and ask them to complete it. For step 2, they might say it does
not matter if the rooms are upstairs or downstairs or if the keys are on a fob/keyring, but it matters which room the keys might be in, but it doesn’t matter what they
might be placed on (for example). Ask students to suggest and share additional abstractions. (See the lost cat algorithm here for ideas –
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5789300/)
There is no fixed solution to this problem, which is something to highlight with students once the task is completed. Remember, the abstracted solution should
work for anyone, anywhere, who has lost their keys.
Plenary

14
© Pearson Education Ltd 2019. Copying permitted for purchasing institution only. This material is not copyright free.
Ask students to share their algorithms with the class, and invite peer feedback.
Additional Activity

An extension activity could include looking for keys and a phone.


Digital Resources

Hardware: Additional resources:


None Year 9, Unit 1, Lesson 5, Worksheet 1
Recommended software Year 9, Unit 1, Lesson 5, Worksheet 2
None

15
© Pearson Education Ltd 2019. Copying permitted for purchasing institution only. This material is not copyright free.
Year 9, Unit 1: Search and Sort Algorithms, Lesson 6

Main Focus Prior Knowledge Key Vocabulary Curriculum Objectives

Solving a coding Students should be familiar with abstraction, guess, PS9.1B Understand how bubble sort and linear search algorithms work.
problem, including algorithm methods, coding and coding algorithm
PS9.1C Understand how abstraction can be used effectively to model
abstraction, abstraction.
aspects of the real world.
algorithm writing
and coding PS9.2A Be able to design computational abstractions that model the state
and behaviour of real-world problems and physical systems.
PS9.2B Be able to program abstractions of real-world examples.
PS9.2C Be able to describe/demonstrate a search algorithm and program it.
PD9.2B Understand and use subprograms that implement parameters and
return values.
Teaching Summary

Students will learn about coding a linear search problem.


Start the lesson by searching for a student in the class (tell them to imagine there is a new teacher who has a class list but does not know who sits where). A
linear search would be the new teacher asking one by one, ‘Are you Sergio?’. Sergio might be the last person the teacher asks. Ask students if this kind of search
works sorted or unsorted and ask them to explain (it does not matter). If Sergio was the last person in a class of 100 students, it would take a long time to find him.
Searching is an everyday task (how many times have students ‘Googled’ this week?). With students, abstract the Sergio problem above (recall with students that
the abstract should apply to all teachers who come in and need to find Sergio):
● we need to know the name of the pupil
● we do not need to know their gender
● it is not important what time it is
● we need to know who the new teacher has asked.
This is a physical problem – identifying a student. Other such physical systems might be locating some milk in a supermarket, finding a book in a library or
bookshop, finding a music CD in a shop.
Main Activity

16
© Pearson Education Ltd 2019. Copying permitted for purchasing institution only. This material is not copyright free.
Students should code a solution for the linear search. Teachers may choose any programming environment. An example of a Python solution is shown below.
Students may need to be provided with incomplete code, code with errors to edit and complete code (depending on ability, as in previous lessons).
This is code for a number guessing game:
print(“Choose a number from 1 to 10.”)
choice = 0
answer = “n”
while answer = “y”:
choice = choice + 1
answer = raw_input(“Is it” + str(choice) + “? (y/n):”)
print(“Your number is” + str(choice) + “.”)

Students need to program a guessing game for a random number between 1 and 10. With students, use questions to abstract the problem:
● What is the least and highest number of guesses?
● Are numbers in any particular order or random?
● What happens when we guess a number correctly/incorrectly – what is the return value in each case (if appropriate)?
● (add as appropriate)

Students should write algorithms for the problem, then try to code their solutions. Teachers should check algorithms before moving on to coding.
The following websites have sample solutions that can be modified for this task:
● Python – https://code-maven.com/number-guessing-in-python
● Various – https://www.rosettacode.org/wiki/Guess_the_number

To support students, teachers might prepare a range of support programming resources:


● a complete solution for students to edit and see how changes affect the program (Core/Support)

17
© Pearson Education Ltd 2019. Copying permitted for purchasing institution only. This material is not copyright free.
● a complete program with the lines of code mixed up to be sorted correctly and tested (Core)
● a complete program that has a few errors that need to be found and edited (Support)
● more able students may code from scratch (Extend).
Teachers can choose any suitable programming environment.
Plenary

Students share solutions and take peer feedback.


Additional Activity

None.
Digital Resources

Hardware: Additional resources:


For STUDENT USE: Computers
Recommended software:
Suitable programming environment

18
© Pearson Education Ltd 2019. Copying permitted for purchasing institution only. This material is not copyright free.
Year 9, Unit 1: Search and Sort Algorithms, Lesson 7

Main Focus Prior Knowledge Key Vocabulary Curriculum Objectives

Introduction to Students should be familiar with binary, search, PS9.1B Understand how bubble sort and linear search algorithms work.
binary searching linear/serial searches and what an average
PS9.2C Be able to describe/demonstrate a search algorithm and program it.
and testing average is (mean).
solutions PD9.2B Understand and use subprograms that implement parameters and
return values.
Teaching Summary

Students are introduced to binary search through an ‘unplugged’ activity. They then review possible solutions and present the solutions to the rest of the class.
With students, list the problems/advantages with the linear sort:
● time consuming if the last record checked is the one wanted – it can be slow to produce results (-)
● search items can be unsorted (+)
● simple algorithm/simple coding (+)
● works with most data types (+)
● if the list of items is updated – merge or linear – the algorithm still works (+)
● works well with shorter lists (+).
Highlight again why sorting is important to a search and why search algorithms are important for students to understand.

The biggest drawback of a linear search is the speed. A different search method is needed when there are thousands/millions of records (or billions of web
pages) to check.

Introduce the binary search method. Teachers can demonstrate a binary search. There are a range of ‘unplugged’ activities that explain a binary search without
the need for a computer. The following might be useful for teachers:
● https://www.youtube.com/watch?v=iDVH3oCTc2c (a demonstration of binary method to a class of children)
● https://www.youtube.com/watch?v=wVPCT1VjySA (a ‘divide and conquer’ tale about Santa’s dirty socks getting mixed in with presents!)
● https://www.youtube.com/watch?v=lhlBWlhS7Vg&feature=youtu.be&list=PLhQjrBD2T383Q2VtqEaQn8nZh-681av20&t=1198 (a demonstration of binary
19
© Pearson Education Ltd 2019. Copying permitted for purchasing institution only. This material is not copyright free.
search using a phone book)
● https://www.khanacademy.org/computing/computer-science/algorithms/intro-to-algorithms/a/a-guessing-game (guessing game that illustrates the different
levels of efficiency in different algorithms)

When choosing and running an activity, highlight the following:


 the parameters to the program will be the list and the target value
 the return value of the program will be the location where the target value was found.
(See video at https://www.youtube.com/watch?v=mGaamvgPqpw for an explanation using Python.)

An important point about the efficiency of a binary search is highlighted in the first video. It takes 20 steps to find one number in a million, whereas a linear search
would need up to a million steps to find the millionth value.
Teachers should emphasise that binary searching only works if the list to be searched is sorted (ascending numerically for number searches or alphabetically for
text searches).
Main Activity

Hand out Worksheet 1 and set students the task to review and check one of the possible solutions provided to see if it works. (Does it sort a given list of
numbers?) They will need a list of numbers to use: teachers can provide any simple list – perhaps one that is locally suitable? Students should be divided into four
groups, each group to work on one of the four solutions. The worksheet should be cut up so that teachers can hand one solution to each group. (Teachers can
supplement the solutions on Worksheet 1 with any locally suitable solution or one that might lead into the coding in the following lessons.)
 Core – all solutions possible
 Support – top solution is more accessible.
Once students have tested and checked the solution, they will need to present and demonstrate it to the class. They should prepare this presentation to ensure
that it will work.
Groups present their solutions to the class.

Plenary

Ask students for their opinions on the different solutions. What do they have in common? How efficient are they? Do students understand the terms ‘mean’ and

20
© Pearson Education Ltd 2019. Copying permitted for purchasing institution only. This material is not copyright free.
‘average’? What if the list to be searched was not sorted?
Additional Activity

Teachers might group students in the main activity and set the more able group the fourth solution, which does not include a sorting step. This could be a potential
problem to solve for students.
Digital Resources

Hardware: Additional resources:


None. Year 9, Unit 1, Lesson 7, Worksheet 1
Recommended software:
None.

21
© Pearson Education Ltd 2019. Copying permitted for purchasing institution only. This material is not copyright free.
Year 9, Unit 1: Search and Sort Algorithms, Lesson 8

Main Focus Prior Knowledge Key Vocabulary Curriculum Objectives

Coding a solution Students should be familiar with binary, solution, PS9.1B Understand how bubble sort and linear search algorithms work.
to a binary search coding and how a binary search code, program
PS9.2B Be able to program abstractions of real-world examples.
problem works.
PS9.2C Be able to describe/demonstrate a search algorithm and program it.
PD9.3A Be able to locate and fix syntax and logic errors in a program.

Teaching Summary

Students choose a solution to a binary search to code and start to code that solution.
 Ask students to recall why a linear search could be very slow (use the word ‘inefficient’) and why it is simplified (does not need sorting). Also recall why a
binary search can be more efficient (fewer steps to find something) but requires additional programming to sort the list before searching.
 You can mention that in the real world, speed is everything in computing – apps that work slowly will not be highly rated and therefore not purchased. If an
app contains a sorting algorithm that is linear, it would be much slower than one that used a binary sort.
 This is a two-part lesson: in part 1 (Lesson 8), students need to code a solution to a binary search. In part 2 (Lesson 9), they will need to use tools to
check for errors, then locate and fix those errors. Teachers may use any locally suitable programming environment. Teachers can decide to group
students or let them work alone (or a mixture depending on ability and level of support required).
Main Activity

Starting points for the coding of the binary search could be one of the solutions (algorithms) in Lesson 7 (that has been checked and corrected for any errors).
You might want to produce a range of prepared resources for students based on one of the four solutions in Lesson 7 (or write your own). These provided
solutions might include:
● a fully coded solution for less able students to edit and test how those edits affect the program (support)
● a complete solution with key errors (syntax, logic) that need finding and fixing (support)
● a complete working solution that requires students to re-order the lines of code to work correctly (core/support)
● a partial solution with lines missing (core)
● more able students might code from scratch, choosing which solution to solve.

22
© Pearson Education Ltd 2019. Copying permitted for purchasing institution only. This material is not copyright free.
Students are set problems matched to their ability and start work on the coding part of this two-part lesson.
Plenary

At the end of the lesson, ask students to review the work in progress and write down two things that they need to do in the next lesson. They can share these with
the class. Teachers can use this to monitor progress.
Additional Activity

None
Digital Resources

Hardware: Additional resources:


For STUDENT USE: Computers
Recommended software:
Locally suitable IDE

23
© Pearson Education Ltd 2019. Copying permitted for purchasing institution only. This material is not copyright free.
Year 9, Unit 1: Search and Sort Algorithms, Lesson 9

Main Focus Prior Knowledge Key Vocabulary Curriculum Objectives

Testing a Students should have experience of test plan, syntax PS9.1B Understand how bubble sort and linear search algorithms work.
programming coding a solution and checking for error
PS9.2B Be able to program abstractions of real-world examples.
solution using a errors in a solution.
test plan to find PS9.2C Be able to describe/demonstrate a search algorithm and program it.
and fix syntax PD9.3A Be able to locate and fix syntax and logic errors in a program.
and logic errors
Teaching Summary

Students will complete their coding project from Lesson 8 and use testing methods to check it works as expected.
Main Activity

Ask students to recall the review they did in the previous lesson. Students to note down what they need to do to complete and test their solutions. Give students 5
minutes to carry out this review (they may need to view their ongoing work).
Once they have carried out this review and noted down what they need to do, they may start testing. Teachers can move around the class reviewing the notes
they made and helping them with any issues.
It is likely that students might need to check code as they go, so they will be testing as the program is running.

In the final part of the lesson (when students are ready) they should fully test their solutions, checking for syntax errors and for logic errors. Worksheet 1 contains
a table to plan their testing and review the results of testing. Students who are struggling might use the plan to help them analyse the wrongly coded version
provided by teachers in Lesson 8.

You can give an example of what to add to the table, such as:
● software feature – program ends when searched for record is found
● test data/text – choose a record to look for
● expected output/result – program ends
● actual output/result – program ended

24
© Pearson Education Ltd 2019. Copying permitted for purchasing institution only. This material is not copyright free.
● action required – none

Peers should review each other’s solutions and provide feedback.


Plenary

With the class, ask students to share any issues they found in their coding and how they fixed them.
Additional Activity

The complexity and starting point in this mini-project will provide extension for more able students. If they complete this project and have time, they could see if
they can change their program to locate a word in a list.
Digital Resources

Hardware: Additional resources:


For STUDENT USE: Computers Year 9, Unit 1, Lesson 9, Worksheet 1
Recommended software:
IDE – teacher may choose a suitable one as a preference

25
© Pearson Education Ltd 2019. Copying permitted for purchasing institution only. This material is not copyright free.
Year 9, Unit 1: Search and Sort Algorithms, Lesson 10

Main Focus Prior Knowledge Key Vocabulary Curriculum Objectives

Review of Unit 1 algorithm, merge, PS9.1B Understand how bubble sort and linear search algorithms work.
through group search, sort,
PS9.2C Be able to describe/demonstrate a search algorithm and program it.
role play linear

Teaching Summary

Students create an active presentation/demonstration of a topic from Unit 1.


During this unit, teachers may have used various video stimuli for students that show coding and algorithms through different active ways – dance, play, etc. In
this final lesson, the unit is reviewed through students being set a task to model one of the topics in a similar way to those they may have seen.
Recall with students the main topics covered:
● bubble sort
● merge sort
● linear search
● binary search
● algorithms
● abstraction
● testing.

Main Activity

Divide the class into suitable group sizes (groups of three or four would be best) and issue each group with a task:
● create an algorithm dance routine (https://www.youtube.com/watch?v=Qhy6pm2-zY4)
● demonstrate a binary search through dance/demo (https://www.youtube.com/watch?v=iDVH3oCTc2c&t=5s)
● demonstrate a sort (https://www.youtube.com/watch?v=ywWBy6J5gz8 or https://www.youtube.com/watch?v=WuGvUFvG7yo)

26
© Pearson Education Ltd 2019. Copying permitted for purchasing institution only. This material is not copyright free.
If there are many groups, some groups can do the same task. Allow sufficient time for students to plan and rehearse their presentation.
Students present their work.
Plenary

In the final part of the lesson and unit, ask students to reflect on their learning – what they did well in the unit and one thing they could improve.
Additional Activity

More able students might be set together and given a more challenging task to demonstrate, such as a merge sort.
Digital Resources

Hardware: Additional resources:


None
Recommended software:
None

27
© Pearson Education Ltd 2019. Copying permitted for purchasing institution only. This material is not copyright free.

You might also like