Key Stage 3 Computing

Download Scratch Bubble Sort (http://tinyurl.com/chteb66)

Lesson 1

Searching for information

Learning outcome - Understand that efficient information searches require strategies.

Activity 1

Work in groups. Each group has a pack of playing cards containing 1 Joker.

One member of the group shuffles the pack of cards. Another then takes the deck face down and chooses one card at a time unitl they find the Joker. How many choices did it take? Are there strategies that make finding the Joker any quicker? Share the results with the rest of the class.

Generally if you have no idea where the Joker is and you can't see it, any order of selection of cards is going to be as good as any other.

What if we turn the cards over? It seems obvious we can recognise the joker and go straight to it. But to do that some sophisticated recognition is taking place. We have to know why the joker looks different from the other cards in order to identify it. If yo had never played cards before someone would have to explain the difference in such a way that you could use that information to recognise the Joker was not a King or a Jack or a Seven. Computers have to be given information to match to other information to find it in a search. 

Activity 2

Simulating the search in a computer program

What is needed to simulate finding a Joker in a pack of cards?

Make a list of 53 numbers. Make them all number 1. The ones represent all the other cards. Insert a number 2 at a random place in the list of ones in place of one of the number ones. Start at the beginning comparing the numbers in the list to the number 2. When we find the number 2 check how many choices it took. Repeat and see if there is any pattern.

To program this we need to know about the following programming things.

  1. Variables
  2. Lists
  3. Control sturctures.

We will do this in Scratch.

In Scratch a list variable is a list of items that can vary in length and contents. It could be a list of numbers or words. In our first list we will use numbers to represent playing cards. Number 1 for any card other than the Joker and number 2 for the Joker. This is making the problem simpler. Once we get the project to work in this simpler situation it is easier to then make it work for a more realistic situation by adding more to it in simple steps checking each one as we do it. This is a very important thing to learn about computer programming. Try to make problems simple and then build them up to be fully realistic and more complicated. Then if somethng doesn't work it is only likely to be one recent change to find and fix. 

Scratch lists start off empty. They simply have a name you give to the list when you create it. 

When you click on the Make a list button it will set up a space in the computer for your list. You can't see the space directly just a box on the screen to represent the space. 

Give the list a name - in this case we are saying it will represent our pack of cards so we can call it Pack of cards.

You will notice some extra "blocks" appear on the left. These are the building blocks for programming that are associated with our Pack of cards list. 

 

To make a pack of cards, how many cards do we need? Answer

To make a pack of cards with a Joker, how many cards do we need? Answer

So in order to make a simple pack of cards we need to 

  1. Tell Scratch to make a list called Pack_of_cards
  2. Tell Scratch how many items are needed for the list (this is the number of cards)
  3. Put the items into the list that represent ordinary playing cards

To put an extra Joker card into the pack in a random position

  1. Generate a random number between 1 and the number of items in the pack
  2. Put the number that represents the Joker card into the pack at the position of the random number

To find the position of the Joker card

  1. Start at the first card
  2. Check each card until one matches the Joker number

Reset the list

  1. Take out all the items from the list.

We have broken the task down into simple steps. So lets look at programming the first part.