Teaching design techniques to design efficient solutions to problems

Slides:



Advertisements
Similar presentations
Basics of Computer Programming Web Design Section 8-1.
Advertisements

Chapter 3 Planning Your Solution
PROGRAMMING, ALGORITHMS AND FLOWCHARTS
Flow Charting. Goals Create Algorithms using Flow Charting procedures. Distinguish between Flow Charting and Pseudocode. Top-Down Design Bottom-up Design.
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.
Program Design BUILDING A HOUSE. Steps to Designing a Program 1. Define the Output 2. Develop the logic to get that output 3. Write the program.
Algorithms and Pseudocode
Algorithms and Flowcharts
CST 1101 Problem Solving Using Computers
Understand Problem Solving Tools to Design Programming Solutions
Lesson Objectives Aims To be able to write an algorithm in Pseudo Code
3.1 Fundamentals of algorithms
INTRODUCTION TO PROBLEM SOLVING
Chapter One Problem Solving
FLOWCHARTS Part 1.
Basics of Computer Programming
Programming Mehdi Bukhari.
Algorithms and Flowcharts
Lecture 2 Introduction to Programming
Basics of Computer Programming
Basics of Computer Programming
Basics of Computer Programming
Algorithm and Ambiguity
ALGORITHMS AND FLOWCHARTS
Print slides for students reference
Design and Technology Academic Year 2017/2018 Grade 7 First Semester.
Designing and Debugging Batch and Interactive COBOL Programs
Problem Solving Techniques
Pseudocode algorithms using sequence, selection and repetition
Global Challenge Night Sensor Lesson 2.
ALGORITHMS AND FLOWCHARTS
We’re moving on to more recap from other programming languages
Chapter 2- Visual Basic Schneider
Global Challenge Night Sensor Lesson 2.
DO NOW – Decompose a Problem
Introduction to Algorithms and Programming
Global Challenge Night Sensor Lesson 2.
Global Challenge Night Sensor Lesson 2.
Algorithm and Ambiguity
Problem Solving Designing Algorithms.
Global Challenge Walking for Water Lesson 2.
Flowcharting & Algorithms
My Take on the Largest Number Algorithm
Global Challenge Night Sensor Lesson 2.
Global Challenge Walking for Water Lesson 2.
Software Development Process
No Yes START Do you live in Scotland? Take umbrella See last Flowchart
Global Challenge Walking for Water Lesson 2.
Global Challenge Night Sensor Lesson 2.
Global Challenge Night Sensor Lesson 2.
Data and Flowcharts Session
Flowcharts and Pseudo Code
ICT Gaming Lesson 2.
Global Challenge Night Sensor Lesson 2.
COMPUTATIONAL THINKING COMPUTATIONAL THINKING IN PROGRAMMING
Global Challenge Walking for Water Lesson 2.
Data and Flowcharts Session
Developing a Program.
Global Challenge Walking for Water Lesson 2.
Global Challenge Walking for Water Lesson 2.
Global Challenge Night Sensor Lesson 2.
Global Challenge Night Sensor Lesson 2.
Global Challenge Walking for Water Lesson 2.
WJEC GCSE Computer Science
Global Challenge Walking for Water Lesson 2.
Global Challenge Walking for Water Lesson 2.
Global Challenge Walking for Water Lesson 2.
Software Development Techniques
Counting and estimation
Introduction to Programming
Presentation transcript:

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

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

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.

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.

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.

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!

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

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.

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.

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

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?

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

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

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

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

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?

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.

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

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.

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

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!

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

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

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

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.

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

Let’s design a solution that creates the following pattern

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

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

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.

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

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

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

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

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?

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

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 https://community.computingatschool.org.uk/resources/2324