Presentation is loading. Please wait.

Presentation is loading. Please wait.

Teaching design techniques to design efficient solutions to problems

Similar presentations


Presentation on theme: "Teaching design techniques to design efficient solutions to problems"— Presentation transcript:

1

2 Teaching design techniques to design efficient solutions to problems
National 5 Computing Science Teaching design techniques to design efficient solutions to problems

3 Aims to link computational thinking with design
to look at approaches to teaching design

4 Computational Thinking
The thinking that is undertaken before starting work on a computer. It describes the process and approaches we draw on when thinking about problems in such a way that a computer can help us.

5 Decomposition Breaking down of a problem into smaller parts.
solving smaller problems is easier solving of the problem can then be shared Decomposition can be applied to all types of day to day problems. Leads naturally to modularity.

6 Brainstorming Choose destination Book flights
Annual leave permission from boss Preparing for a holiday Book hotel Choose dates Get currency Although we have split the problem into smaller chunks we now need to organise it into a logical order.

7 Why is the order important ? Some things may be dependant on others
Choose destination Choose Dates Annual Leave permission from boss Book Flights Book Hotel Get currency P e r f e c t S c e n a r i o Bremen 10th – 16th October Booked with Bookingmyholiday.com Change pounds to Euros Yes Booked with Ryanair Unfortunately life isn’t always smooth!

8 What we have here is a loop
Annual Leave permission from boss Choose destination Choose Dates Repeat until boss gives permission Choose Dates Bremen 10th – 16th October No ! 15th to 21st October No ! 5th to 10th November Yes

9 Suggested decomposition lessons
Candidates brainstorm a problem then work together in pairs to produce a logical sequence of steps. Candidates are given a sequence of steps (preferably cut out blocks) that are not in the correct order and working together in pairs put them into a correct sequence.

10 Algorithms What we have been creating is called an algorithm.
An algorithm is a sequence of instructions or rules to get something done. This is how we can design solutions that we can code computers to solve. We use algorithms in other areas of life eg recipes for cooking directions for getting to places diagnosing patients There are different ways of representing algorithms.

11 Structure diagrams Show the solutions to problems using only 3 types of construct Process such as a calculation Loop where part of the problem repeats a fixed number of times or repeats until conditions are met Selection where the problem may branch depending on the conditions met

12 The structure diagrams are read from the top down and from left to right.
If your numbers are 2, 4 ,7, 1 and 6 what is displayed? Can you use this algorithm to find the average of 10 numbers?

13 This algorithm calculates interest for a loan
Total = £ 2140 What would the output be if you wanted to borrow £ 2,000 Loan = £ 30000 Interest =£ 1500 Total = £ 31500 What would the output be if you wanted to borrow £ 30,000 What would the output be if you wanted to borrow £ 10,000 Loan = £ 10000 Interest =£ 700 Total = £ 10700

14 This algorithm calculates the cost of carpeting a house
Fill in the blanks

15 Flow charts Show the solutions to problems using a number of different symbols Flow line shows the flow between symbols Terminal represents the start and end of the process Initialisation of a variable Input/ Output of data Decision where the problem may branch Process such as a calculation Used to split a flowchart up it it’s too big for the page

16 A flow chart starts from the top and works it’s way down following the flow of the arrows.

17 What problem is this flowchart solving?
What output would you have if the ages that were typed in from the keyboard were 32, 17, 25, 24, 39, 65 What test data should you use to test this flowchart works? Why do we set the age and counter to 0 initially?

18 Pseudocode Is a kind of structured English for describing algorithms and is intended for human reading. Pseudocode can look like code in an implemented problem but it doesn’t have the same strict syntax. Most pseudocode uses IF… THEN…ELSE.. Type statements for selection Repeat… UNTIL Type statements for repetition The design should begin by defining the main steps of an algorithm. Where a step of the algorithm requires refinement, a numbering system may be used to denote which line of the algorithm is being refined. Identified selection and repetition in the problem, may be highlighted with indentation.

19 Calculating the volume of water in a swimming pool
Algorithm 1 Ask user to enter dimensions of a swimming pool in metres 2 Calculate volume of pool 3 Display message stating the volume of the pool Refinement 1.1 Ask user to enter length of pool 1.2 Ask user to enter width of pool 1.3 Ask user to enter depth of pool 2.1 Volume is calculated as length times width times depth 3.1 Display “The volume of the pool is”, volume

20 What does this algorithm do?
Set answer to 77 Set guess to 0 Repeat get guess IF guess equals answer THEN display Well guessed ELSE IF guess is greater than answer THEN display Too High display Too Low END IF UNTIL answer equals guess What tests would you use to check that your algorithm worked? The guess is only meant to be between 0 and 100. How can we change the algorithm to limit the guess? Alter the algorithm.

21 Set answer to 77 Set guess to 0 Repeat get guess IF guess<1 OR guess>100 THEN display you must enter a number between 1 and 100 END IF Until guess>0 AND guess <101 IF guess equals answer THEN display Well guessed ELSE IF guess is greater than answer THEN display Too High display Too Low UNTIL answer equals guess We call this input validation It is used in many programs where the user is restricted in what they should enter

22 Problem Design a solution for deciding the category of a parcel using the following criteria: small parcel has a maximum weight of 2kg medium parcel has a maximum weight of 20kg large parcel is anything heavier than 20kg Get a partner to check that it works!

23 Flowchart Ask for the weight of the parcel Is the weight
<=2Kg Yes It’s a small parcel No Is the weight >20Kg It’s a Large parcel Yes No It’s a medium parcel

24 Structure diagram Ask for the weight Is the weight of the parcel
<=2Kg No Yes Is weight>20Kg It’s a small parcel Yes No It’s a large parcel It’s a medium parcel

25 Pseudocode Get weight of parcel If weight of parcel < =2 THEN
parcel size = small ELSE IF weight of parcel >20 THEN parcel size = large parcel size = medium END IF

26 Suggested algorithm lessons
Give candidates an algorithm and ask them to check that it works. This can lead into testing and shows that test data tables can be created at the design stage and then used again at the testing stage. Give candidates a problem solved using different design techniques and get them to check that they all solve the same problem (one could be slightly wrong) Give candidates an algorithm and a variety of inputs and ask them to say what the output would be. Get candidates to match different problem descriptions to completed designs.

27 Patterns and Generalisation
By identifying patterns we can: make predictions create rules solve more general problems create code that makes efficient use of coding constructs

28 Let’s design a solution that creates the following pattern

29 Here is my pseudocode Move forward 100 Turn right 90 degrees Turn right 45 Move forward 100 Turn right 90 degrees Turn right 45 Move forward 100 Turn right 90 degrees Turn right 45 Move forward 100 Turn right 90 degrees Turn right 45

30 We quickly see that the following is repeated 8 times
So we can then re-write the solution using a loop Repeat 8 times Move forward 100 Turn right 90 degrees Turn right 45 End loop Move forward 100 Turn right 90 degrees Turn right 45 It helps if we can recognise patterns at the start of the design process

31 We can see that there is a further repetition
So we can then re-write the solution using another loop Repeat 8 times Move forward 100 Turn right 90 degrees Turn right 45 End loop Repeat 8 times Repeat 4 times Move forward 100 Turn right 90 degrees End loop Turn right 45 I would have started to talk about a procedure for the drawing of the square at this point.

32 Write an algorithm that simulates access to a cash machine where you get 3 attempts to enter the correct PIN. Does it work? Is there a pattern? Can you make it more efficient ? Try Re-writing the structure diagram

33 We have to initialise the counter to 0 at the start
We have to have an action if the PIN isn’t correct after 3 attempts We have to use a counter to keep track of how many opportunities we give the user to get the PIN

34 Write an algorithm that simulates a code activated door system in a hotel where guests are given three opportunities to put in the correct code to open their room. Does it work? Is there a pattern? Can you make it more efficient ? Try Re-writing the flowchart

35 We have to initialise the counter to 0 at the start
We have to have an action if the PIN isn’t correct after 3 attempts We have to use a counter to keep track of how many opportunities we give the user to get the PIN

36 Is there some redundancy in this algorithm?
This algorithm simulates security access where only the users Staff and Admin have access. Is there some redundancy in this algorithm? Do we need to ask this?

37 The algorithm is a little simpler
This version does the same task but without the early opt out if the User ID is wrong The algorithm is a little simpler

38 Summary Before using a computer use your brain – it’s more powerful!
take a problem decompose it into smaller parts write an algorithm is it efficient? does it work? Test it Now you can start to code For more information on computational thinking see the Computing at School guide

39


Download ppt "Teaching design techniques to design efficient solutions to problems"

Similar presentations


Ads by Google