- Slides: 61
Computational Thinking GCSE Computer Science
Learning Objectives • To understand that you can tackle big problems by breaking them down into smaller parts using Computational Thinking. • To understand the four parts of Computational Thinking; decomposition, pattern recognition, abstraction and algorithms. • To create your own solutions to problems using Computational Thinking. ?
• Why are we learning? (Purpose & Goals) We are learning how to overcome complex problems • How are we learning? (Skills, Techniques, Software, etc. ) We will be using a strategy known as Computational thinking • What are we learning? (Knowledge) We are learning the four elements of computational thinking: • Decomposition • Pattern Recognition • Abstraction • Algorithm ?
Key words • Decomposition: breaking down a complex problem or system into smaller, more manageable parts. • Pattern Recognition: looking for similarities among and within problems. • Abstraction: focuses on the important information only, ignoring irrelevant detail. • Algorithms: a step-by-step solution to the problem, or the rules to follow to solve the problem.
Introduction to 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. There are four key techniques to computational thinking:
How does it work? Computational thinking involves taking that complex problem and breaking it down into a series of small, more manageable problems (decomposition). Each of these smaller problems can then be looked at individually, considering how similar problems have been solved previously (pattern recognition) and focusing only on the important details, while ignoring irrelevant information (abstraction). Next, simple steps or rules to solve each of the smaller Finally, these simple steps or rules are used problems can be designed to program a computer to help solve the (algorithms). complex problem in the best way.
Thinking Computationally • Thinking computationally is not programming. It is not even thinking like a computer, as computers do not, and cannot, think. • Programming tells a computer what to do and how to do it. Computational thinking enables you to work out exactly what to tell the computer to do. • Being able to turn a complex problem into one we can easily understand is a skill that is extremely useful. In fact, it's a skill you already have and probably use every day. • Watch the following video: https: //www. youtube. com/watch? v=SVVB 5 RQf. Yxk
Thinking Computationally Task 1 You are meeting up with a group of friends this afternoon. All of you like different things, but you have been put in charge of finding something to do that will keep most of your friends happy. Think of some questions could you consider in order to come up with a plan? Consider: Time Money Weather Friends Interests Possible questions to consider E. g. where could you go? From this information, do you think that you and your friends could decide more easily where to go and what to do – in order to keep most of your friends happy?
Thinking Computationally Task 2 Look at the videogame screen to the right. What do you need to consider in order to complete the level as efficiently as possible? Possible questions to consider E. g. What items do I need to collect? From these details you can work out a strategy for completing the level in the most efficient way.
Thinking Computationally Task 3 Computational Thinking Explanation Example 1 – Meeting up with friends Task: Can you put the correct statements below in the table? They have been colour coded to help you! Example 2 – Creating a computer game Decomposition Pattern Recognition Abstraction Algorithm Options of where to go Focusing on the important information only, ignoring irrelevant detail. What you have previously done that has been a success in the past Explanation of how to complete the level Developing a step-by-step solution to the problem, or the rules to follow to solve the problem. Including similar features used within similar games Location of the exit Breaking down a complex problem or system into smaller, more manageable parts. Looking for similarities among and within problems. Weather conditions Where your going to go, how to get there, what time to meet and go home Ways of getting to the exit
Decomposition • Decomposition involves breaking down a complex problem or system into smaller parts that are more manageable and easier to understand. The smaller parts can then be examined and solved, or designed individually, as they are simpler to work with. • If a problem is not decomposed, it is much harder to solve.
Decomposition Task 1 A crime has been committed. Solving a crime can be a very complex problem as there are many things to consider. The police officer needs to know the answer to a series of smaller problems. Look at the crime scene; what problems do you think the police officer needs to consider? Considerations
Decomposition Task 2 How would you decompose the problem of making a sandwich? Think of questions you need to know the answers to in order to make a sandwich for someone else! Considerations
Developing Decomposition Task 3: Articulate! • Get into groups of 4, 2 vs 2! • Each pair gets a pack of articulate cards. • You have 30 seconds to try and describe as many items as you can (use the clock feature to time). • One partner must describe what is on the card without using the name of the item. If the partner answers correctly, the team get a point. • If the name of the item is used the team get -1 point. • The team with the most points at the end wins! • Only one pass is allowed per turn. Use it wisely!
Pattern Recognition • When we decompose a complex problem we often find patterns among the smaller problems we create. The patterns are similarities or characteristics that some of the problems share. • Pattern recognition is one of the four cornerstones of Computer Science. It involves finding the similarities or patterns among small, decomposed problems that can help us solve more complex problems more efficiently.
Pattern Recognition Task 1: Sudoku! The classic Sudoku game involves a grid of 81 squares. The grid is divided into nine blocks, each containing nine squares. The rules of the game are simple: each of the nine blocks has to contain all the numbers 1 -9 within its squares. Each number can only appear once in a row, column or box. Use your pattern recognition skills to solve the puzzle! Rookie Pro BEAST!
Why do we need to look for patterns? • Finding patterns is extremely important. Patterns make our task simpler. Problems are easier to solve when they share patterns, because we can use the same problem-solving solution wherever the pattern exists. • The more patterns we can find, the easier and quicker our overall task of problem solving will be. • To find patterns among problems we look for things that are the same (or very similar) for each problem.
Pattern Recognition Task 2 Look at the two cakes to the below. From the instructions provided can you identify any similarities in how to prepare them? Similarity 1 2 3 4 Once we have the patterns identified, we can work on common solutions between the problems.
Pattern Recognition Task 3 1. Consider a typical week. Write a list of the things you do that are the same from day to day. 2. How do you think having a pattern with these consistencies benefits you?
Abstraction is the process of filtering out – ignoring - the characteristics of patterns that we don't need in order to concentrate on those that we do. It is also the filtering out of specific details. From this we create a representation (idea) of what we are trying to solve. Abstraction allows us to create a general idea of what the problem is and how to solve it. The process instructs us to remove all specific detail, and any patterns that will not help us solve our problem. This helps us form our idea of the problem. This idea is known as a ‘model’.
Can you add the statements below into the correct table columns. Some of them are General Statements, others are Specific Details. How to Abstract Task 1 General Patterns When baking a cake, there are some general characteristics. For example: • a cake needs ingredients • each ingredient needs a specified quantity • a cake needs timings A cake needs ingredients. When abstracting, we remove specific details and keep the Cake needs a specified general relevant patterns. time to bake. Know the specific ingredient quantities. Specific Details A Victoria sponge cake has a layer of strawberry jam in the middle. It takes 1 hour 45 minutes to cook a Christmas cake. Banana cake uses 600 g of sliced bananas.
Abstracting Task 2: Football team Using the statements below, can you identify the ones that are useful (General Patterns) and those that are not (Specific Details) in in explaining the model of a football team. General Patterns Specific Details Roy Hodgson is the England team Manager A football team is made up of 11 players. Players wear a shirt, shorts, socks and football boots. A team is made up of a goalkeeper, defenders, midfielders and forwards. Gareth Bale is a Welsh International player Manchester United’s home kit is Red FC Barcelona play with one goalkeeper, three defenders, four midfielders and three strikers. A football team is run by a manager
Algorithms An algorithm is a plan, a set of step-by-step instructions to solve a problem. If you can tie shoelaces, make a cup of tea, get dressed or prepare a meal then you already know how to follow an 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, and they are sometimes written as a flowchart or in pseudocode.
Code needs algorithms! • You use code to tell a computer what to do. Before you write code you need an algorithm. • An algorithm is a list of rules to follow in order to solve a problem. • Algorithms need to have their steps in the right order. Think about an algorithm for getting dressed in the morning. What if you put on your coat before your jumper? Your jumper would be on top of your coat and that would be silly! When you write an algorithm the order of the instructions is very important. • Watch the following video: http: //www. bbc. co. uk/guides/z 3 whpv 4
How do you use algorithms? People use lots of algorithms every day even if they don’t realise it. Choose from three problems and guess what the algorithm might be! We need to make a cake! The algorithm here is a cake recipe. You can find the algorithm to solve this problem in a cookbook! We can’t find the park! The algorithm you need is a set of directions to get to the park! There might be different ways to the park so you can have different algorithms. We need to build a toy! The algorithm to follow here is the list of instructions that tell you how to make the toy.
Task 1: Clear instructions • When you write an algorithm you need to include precise, step-by-step instructions. • Task: Can you put the following instructions in order for making a smoothie: Imagine if we missed out one of the steps or reversed the order. We could end up switching on the blender with nothing in it. Or there could just be milk in the blender and no fruit. That wouldn't make a very tasty smoothie, would it? In fact, it wouldn't make a smoothie at all! Step 1 Add milk to the blender Step 2 Put the lid on the blender Step 3 Switch the blender on Step 4 Add fruit to the blender
Representing an Algorithm: Pseudocode • Pseudocode is not a programming language, it is a simple way of describing a set of instructions that does not have to use specific syntax. • Writing in pseudocode is similar to writing in a programming language. Each step of the algorithm is written on a line of its own in sequence. Usually, instructions are written in uppercase, variables in lowercase and messages in sentence case. • In pseudocode, INPUT asks a question. OUTPUT prints a message on screen.
Pseudocode Example Task • A simple program could be created to ask someone their name and age, and to make a comment based on these. This program represented in pseudocode would look like this: OUTPUT 'What is your name? ' INPUT user inputs their name STORE the user's input in the name variable OUTPUT 'Hello' + name OUTPUT 'How old are you? ' INPUT user inputs their age STORE the user's input in the age variable IF age >= 70 THEN OUTPUT 'You are aged to perfection!' ELSE OUTPUT 'You are a spring chicken!' Try it out! In pairs, one of you is the computer, the other is the user. Talk through the conversation and see if it makes sense! In programming, > means ‘greater than’, < means ‘less than’, ≥ means ‘greater than or equal to’ and ≤ means ‘less than or equal to’.
Task 2: Writing Pseudocode Using the rules set in the last example, write a pseudocode so that the computer asks a true or false question. If the user answers true then a congratulations message is shown, but if the answer is false output a message to say they were wrong. Write your pseudocode here:
Representing an Algorithm: Flowcharts • 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.
Arrows are used to show the direction of flow within the algorithm. Presenting an Algorithm as a Flowchart These are the basic building blocks of a flowchart algorithm: Start / End Process Decision Input / Output True Start Add 5 Is x > 10? The boxes at the start/end are written using ‘rounded rectangles’. A start symbol represents the start of a process and produces exactly one output. An end symbol represents the end of a process and has exactly one input. Process are written in a rectangular box. It represents an operation (or task) to be carried out. False When the algorithm has to make a decision, it is written in a rhombus. It has one input and two outputs. Input Name Parallelograms show inputs and outputs
Flowchart Example Task This flowchart shows the equivalent code from the pseudocode example! Try it out! In pairs, one of you is the computer, the other is the user. Talk through the conversation and see if it makes sense! Start Output “What is your name? ” Input User inputs their name Store user name Output “Hello” + name Output “How old are you? ” Input User inputs their age Store user’s age Is age>= 70? Output “You’re a spring chicken!” Output “You’re aged to perfection!” End
Flowchart Task Complete the previous example using the correct flowchart symbols.
Presenting an Algorithm as a Flowchart Consider this simple algorithm for calculating how old a dog is in dog years. It contains three steps, all in sequence In pseudocode, the algorithm would look like this OUTPUT 'How old is your dog? ' INPUT user inputs their dog's age in human years STORE the user's input in the human_years variable dog_years = human_years * 7 OUTPUT 'In dog years, your dog is aged' + dog_years Representing sequencing in a flowchart?
Presenting an Algorithm as a Flowchart
Game show Question Task 3: Flowchart Creation Output: (Your question) Can you recreate your pseudocode question into a flowchart? The symbols have been created for you. Fill them in accordingly. True False
Task 4: Flowchart Practice • If your lamp doesn’t work, what would you do? • Complete the broken lamp algorithm by adding the sentences below; 1. 2. 3. 4. 5. Buy new lamp Has the bulb burned out? Plug the lamp in Replace the bulb Is the lamp plugged in? Broken lamp algorithm Lamp doesn’t work True False
Looping Start Watch the following video: https: //www. youtube. com/wat ch? v=k 0 xgj. Uh. EG 3 U Iteration (Loop) Is where a statement is executed in a loop until the program reaches a certain state or the intended operations have been applied. Looping statements: are efficient loops that will continue to loop until the condition is false. This loop keeps on repeating until a false statement is reached. Decision True Action 1 End False
Task 4: Testing a Countdown Clock The aim of the following loop statement is to create a countdown clock. The timer is set to 10 then each loop through it reduces the number by 1 until it gets to 0 and displays “Time up!” Test it works Go through the loop sequence Timer Step Number and see if you get to 0. You can 1 10 do this with a Trace Table (the first part has been started for 2 9 you); Start Set time to 10 (time=10) time >0 True time = time-1 At what step would the statement become FALSE? Answer: End False Print “Time up!”
Applying Computational Thinking: Supermarket Sweep! • You have been asked to go to the supermarket to buy food for the week. • But you have agreed to meet friends later. • How can you make your trip to the supermarket as fast as possible while still getting all the required items? i. e. how will you make your shop as efficient as possible?
Break down the problem Computational Thinking Decomposition Pattern Recognition Abstraction Algorithm Task: how can we apply what we have learned so far about Computational Thinking to this problem? Place the statements below into the correct boxes. Application Writing down, step-bystep, the best route through the supermarket Knowing exactly what we need to buy Grouping the items into similar categories Trialling different routes through the supermarket
Part 1: Decomposition - The shopping list bananas milk bread oranges Cheddar butter cheese Coffee apples eggs tea Tomato mayonnais sauce e potatoes carrots croissants chicken Minced fresh tuna beef baked tinned beans tomatoes This is your shopping list. It shows a breakdown of every item you need to get from the supermarket.
Part 2: Pattern Recognition – Grouping the items • Consider the items in the shopping list. Could you group them into similar categories, for example, Fruits, Vegetables, Meat, Dairy etc. • Colour code or move the items on the shopping list so that they are placed within groups. • Give each group a clear title.
Part 3: Abstraction – Trialling routes around the supermarket • On the next slide you will see the layout of the supermarket where you will be going to do your shop. • Considering the items on the shopping list and how you’ve grouped them, use Power. Point draw tools to trial at least three different paths through the supermarket. • Make sure you collect every item on the shopping list. • Which route do you think is the quickest? Can you think of a way of measuring the length of the routes (Decompose this problem using computational thinking!!!)?
Eggs Butter Milk Wine & Spirits Checkout 1 Checkout 2 Checkout 3 Checkout 4 Root Vegetables Fruit Sweets Entrance Vegetables Seafood Floral Deli Meat Baking – Spices - Oil Canned Food – Grains - Sauces Baked Goods Coffee – Tea - Cereal Beverages - Water Beer Condiments Frozen Food Cheese Bakery Berries
Part 4: Algorithm – Writing down clear instructions • On the next slide write down a set of clear instructions to follow in order to follow your chosen route through the supermarket as closely as possible. • Make sure you remember to say what items need collecting. These can be grouped as you have suggested in Part 2: Pattern Recognition. • Add some more lines if required.
Step 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Part 4: Instructions
Part 4: Algorithm - Flowchart Use the space below to create a flowchart of the instructions used within the pseudocode. Make sure you use the correct symbols dependant on if you are giving an instruction for a process or a decision. Another method of presenting an algorithm is through a flow chart. Some people find it easier to demonstrate their plan through this visual method.
Testing Get three of your classmates to test out your instructions and identify any problems encountered. Use the table below to record any problems encountered and what improvements you need to make. Test 1 2 3 Problems Encountered Improvements Made Go back to your instructions and make any required changes. Change the font colour to red for any lines of instructions improved.
Your turn… • Using the structures you have learned through Computational Thinking, choose one of the problems below to solve… Level Rookie Pro Beast Task You have to make your own dinner. Negotiate a typical day at school. Organise a surprise birthday party for a friend. Use the following slides to help structure your solution;
Computational Thinking Checklist Level Task Choose the Rookie task Decomposition – You can break down the task into some sensible parts Rookie Pattern recognition – You consider some patterns Abstraction – You create a simple overview or model of how you want the solution to work Algorithm design – You create an algorithm, which includes some sensible instructions. Testing – Conduct two tests on your algorithm. Make improvements if required. Choose the Pro task Decomposition – You can break down the task into sensible parts Pro Pattern recognition – You can identify patterns, some of which will help you develop an understanding of the problem. Abstraction – You create an overview of your solution plan which mostly makes sense. Algorithm design – You create an algorithm which includes some sensible instructions and logical decision pathways. Testing - Conduct four tests on your algorithm. Make improvements if required. Choose the Beast task Decomposition – You can break down the task into a range of logical parts Pattern recognition – You can identify a range of patterns which help you develop an understanding of the problem. Beast Abstraction – You create a comprehensive and considered overview of your solution which makes sense. Algorithm design – Your algorithm includes logical decision pathways and sound solutions to complex issues (loops). Testing - Conduct six tests on your algorithm. Make improvements if required. Loops are tested using a step test table. Complete
Break down the problem Computational Thinking Decomposition Pattern Recognition Abstraction Algorithm Application
Part 1: Decomposition Methods of tackling this task: • Table • Sentences • List • Mind map Break down the task into sections. The more sections you can break the task down into, the clearer an idea you will have about how to tackle the problem.
Part 2: Pattern Recognition Methods of tackling this task: • Table • Sentences • List • Mind map What patterns can you identify within the task? Are there any consistencies or common trends within the problem you’ve chosen? Identify them here!
Part 3: Abstraction Methods of tackling this task: • Drawings • Flowchart • Action plan (Table, list) What do you want the solution to look like? This could be a model of the physical solution or a plan of what you want to happen.
Part 4: Algorithm - Flowchart Create a step by step explanation of how you will tackle the problem. How will you make the decision? Remember to use the correct symbols!
Step 1 2 3 As an alternative to a flowchart, you can write your instructions in pseudocode. 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Part 4: Algorithm - Pseudocode
Testing Test Which part did you test? Were there any problems? Did you make any improvements? 1 2 3 4 5 6 Test your algorithm Rookie: Conduct two tests on your algorithm. Pro: Conduct 4 tests on your algorithm. Beast: Conduct 6 tests on your algorithm. Test loops using a step test table (next page). Change the font colour to red for any lines of instructions improved.
Step test tables (Beast) Title: Step Title: Value Step Value
Review Question What did you do in order to decompose the problem? What patterns did you recognise from this? How did you use abstraction effectively? What method did you use to write your instructions? Why did you choose this method? What parts of your algorithm did you test? Did you find any errors? What improvements did you make as a result of testing? Answer