Algorithms Abstraction

Similar documents
LO2: Understand strategies and techniques used to improve engineering businesses. Using project monitoring tools GANTT Charts

Computer SCienCe Theme: Software Development

Unit 7: Electrical devices LO2: Understand electrical sensors and actuators Sensors temperature the thermistor

20 CODE CHALLENGES. GCSE (9 1) Computer Science GCSE REFORM. February 2015

Unit R081 Pre-production skills. Work Plans and Production Schedules

Lesson Element Build and test your own capacitor Instructions and answers for teachers

Organelle Speed Dating Game Instructions and answers for teachers

LO5: Understand commercial circuit manufacture

Cambridge Technicals in Business Level 3 Unit 5. Instructions for teachers. Case study: Employee motivation and performance

A LEVEL. Delivery Guide H446 COMPUTER SCIENCE. Theme: Input, Output and Storage. April 2015

Unit R082 Creating digital graphics. File Formats and the Properties of Digital Images and Graphics

CAMBRIDGE PROGRESSION ENGLISH AND MATHEMATICS AND LIFE AND LIVING SKILLS MOVING TOWARDS RETIREMENT A PROJECT APPROACH TO DELIVERY

Biomechanics, Psychology and Physical Training Instructions and answers for teachers These instructions should accompany the OCR resource

Chapter 12 Programming Concepts and Languages

A simpler version of this lesson is covered in the basic version of these teacher notes.

REFERENCE GUIDE 1. INTRODUCTION

GAP CLOSING. 2D Measurement. Intermediate / Senior Student Book

ENGLISH LANGUAGE. A Guide to co-teaching The OCR A and AS level English Language Specifications. A LEVEL Teacher Guide.

HTML5 Data Visualization and Manipulation Tool Colorado School of Mines Field Session Summer 2013

These instructions should accompany the OCR resource Planning, which supports the OCR Level 3 Cambridge Technical in Sport Unit 2 Sports coaching

The Richard Pate School. Draft Year 4 Scheme of Work for Scratch

Teacher Notes Introduction

Scratch Primary Lesson 4

Year 9 set 1 Mathematics notes, to accompany the 9H book.

A LEVEL H446 COMPUTER SCIENCE. Code Challenges (1 20) August 2015

INFOPATH FORMS FOR OUTLOOK, SHAREPOINT, OR THE WEB

Excel Reports and Macros

Microsoft Excel 2013 Tutorial

Excel macros made easy

Chapter 2. Making Shapes

APP INVENTOR. Test Review

Lesson #13 Congruence, Symmetry and Transformations: Translations, Reflections, and Rotations

Goal: Practice writing pseudocode and understand how pseudocode translates to real code.

Published : License : None. INTRODUCTION 1. Learning with Turtle Art

To download the script for the listening go to:

Lesson Element. Culture, Norms and Values Instructions and answers for teachers

GCSE Chemistry. Making Salts Instructions and answers for teachers

1 Introduction. 2 Project Browser. 3 FlowStone Editor

Update on Progress 8 measure and reforms to secondary school accountability framework

SUPPORTING STUDENTS WITH WORKING MEMORY DIFFICULTIES

Medium term Plans for Spring Year 5

Key Stage 3. Scheme of Work. Written by Heaton Moor Digital

Finding and Opening Documents

Using the Mindjet Platform and Templates for Marketing Launch Plans

Introduction to Programming with Python Session 3 Notes

A collection of 9-1 Maths GCSE Sample and Specimen questions from AQA, OCR, Pearson-Edexcel and WJEC Eduqas. Name: Total Marks:

What's new in OneNote 2010

VISUAL ALGEBRA FOR COLLEGE STUDENTS. Laurie J. Burton Western Oregon University

Year 9 mathematics test

Paper 1. Calculator not allowed. Mathematics test. First name. Last name. School. Remember KEY STAGE 3 TIER 5 7

CXQuotes Doors and Windows Quotation software. Cogitrix

User Guide January 10

Microsoft Word Track Changes

Intellect Platform - The Workflow Engine Basic HelpDesk Troubleticket System - A102

Excel 2010: Create your first spreadsheet

CHEMISTRY A. AS and A LEVEL Co-teach Guide. A Guide to co-teaching The OCR A and AS level Chemistry A Specifications.

TITLE: Elementary Algebra and Geometry OFFICE LOCATION: M-106 COURSE REFERENCE NUMBER: see Website PHONE NUMBER: (619)

Communicating Information Using ICT. OCR unit number: 3 Level: Entry 3 Credit value: 3 Guided learning hours: 15

SMART Board Interactive Whiteboard Basics Tip Sheet for ABP Faculty

Google Drive lets you store and share all your stuff, including documents, videos, images and other files that are important to

Decimals and Percentages

Volume of Right Prisms Objective To provide experiences with using a formula for the volume of right prisms.

Creating a Jeopardy Review Game using PowerPoint software.

Fruit Machine. Level. Activity Checklist Follow these INSTRUCTIONS one by one. Test Your Project Click on the green flag to TEST your code

Use this translator to save ArchiCAD layouts/views in DXF/DWG format if you plan to continue

Creating a Resource Library

You can learn more about Stick around by visiting stickaround.info and by finding Stick Around on social media.

MindView Advanced Training Guide (PC)

From Data Modeling to Data Dictionary Written Date : January 20, 2014

Microsoft Office 2010: Access 2010, Excel 2010, Lync 2010 learning assets

QUICK START GUIDE. SG2 Client - Programming Software SG2 Series Programmable Logic Relay

Autumn 1 Maths Overview. Year groups Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7 1 Number and place value. Counting. 2 Sequences and place value.

Course Information for Computing

ENGLISH LITERATURE Candidate Style Answers: An Inspector Calls J. B. Priestley

Flash MX 2004 Animation Lesson

CS 4620 Practicum Programming Assignment 6 Animation

SCRATCH PROGRAMMING AND NUMERACY IN SENIOR PRIMARY CLASSES

Computing Unit Planner: Year 5 Unit 1 Quiz and Game

ALGEBRA. sequence, term, nth term, consecutive, rule, relationship, generate, predict, continue increase, decrease finite, infinite

Better Together. Best regards, Team Gynzy

Activity Builder TP-1908-V02

THE PERSONAL TOUCH. User Guide for the Induction Pack Template. scouts.org.uk/appointment

Introduction to the TI-Nspire CX

Dynamics CRM for Outlook Basics

Use fireworks and Bonfire night as a stimulus for programming

Microsoft Office System Tip Sheet

MICROSOFT OFFICE ACCESS NEW FEATURES

This is how quickly your brain forgets things

Learning Activity Management System TEACHER S GUIDE. October 2006 LAMS V2.0 for The First International LAMS Conference 2006

Transcription:

Algorithms Abstraction Instructions and answers for teachers These instructions should accompany the OCR resource Algorithms - Abstraction activity which supports OCR GCSE (9 1) Computer Science The Activity: This resource comprises of 7 tasks. These simple activities help the students understand the concept of abstraction and how algorithms are used to solve problems. This activity offers an opportunity for English skills development. This activity offers an opportunity for maths skills development. Associated materials: Algorithms Abstraction Lesson Element learner activity sheet. This resource is an exemplar of the types of materials that will be provided to assist in the teaching of the new qualifications being developed for first teaching in 2016. It can be used to teach existing qualifications but may be updated in the future to reflect changes in the new qualifications. Please check the OCR website for updates and additional resources being released. We would welcome your feedback so please get in touch.

Introduction Abstraction is finding patterns and packaging similar looking code into self-contained chunks of code. Packaging allows faster program development as it allows programmers to re-use previously created code, so we don't have to repeat it. This "folder of code" exists on one place in the program and other parts of the program "link" to it, just like web pages link to each other. Imagine, instead of sending somebody a link to something you liked on the internet, you had to copy and paste it inside your message! It would be much less efficient. Apart from the extra time and memory used by this operation, if the page got updated, your recipient will have outdated information, while when sending a link, if they choose to follow it they will get the real upto-date version of the page. It makes for easier maintenance - change the code in one place and the links to this code from elsewhere in your program will not need to be changed. Additionally, when programming as a team, other programmers don't need to know how your part works, they can just link to it - they become users of your program, its workings are hidden from them by what we call "the layer of abstraction". Processing data and implementing formulas requires a particular sequence of steps. It is not always the case and depends on the task. In Cooking, the order in which you add ingredients matters. In Maths, addition doesn't care about which order you add numbers in, while division does. Similarly, in programming, command-line interfaces and batch processing require predetermined order for user input, while with graphical user interfaces, buttons can be clicked in different order, so, no set algorithm for user input is needed. Task 1 This activity will require a widely accessible programming package Scratch 2.0, either in its off-line (application https://scratch.mit.edu/scratch2download/) version or its online version (https://scratch.mit.edu/). It is important that procedures (custom blocks) are supported. Task 1: Drawing polygons in Scratch (will also work in any language with pen capabilities, eg Python Turtle). A square is an example of a polygon with 4 sides and 4 angles. As the angles of a complete polygon need to add to 360 degrees (otherwise, there will be gaps in its perimeter), each of the 4 angles is 360/4=90 degrees, as the pupils will know.

Learners will develop an algorithm to draw a square in Scratch 2.0, first line by line (see file Scratch1.png), then as a procedure (see file Scratch1.png), then as a generic polygon. As you can see, at this stage, calling this procedure doesn't tell us how the shape is drawn; we just use it by supplying the parameters to draw the polygon as we need it. Task 2 Decomposition is the process of breaking a complex problem down in to smaller more manageable portions. Decomposition makes great use of abstraction by identifying common patterns in these portions and reusing the code written for one part on other parts. In this task, learners will look at Chinese letters which are made up of simpler parts and research the process through which the meaning gets composed. Task 3 Algorithmic Thinking A well-known problem involves getting some creatures across the river in the same boat (such as described here: http://en.wikipedia.org/wiki/fox,_goose_and_bag_of_beans_puzzle). Discuss what happens if the farmer uses the wrong algorithm to carry them across? Can you make this problem more complex by introducing another creature that is dangerous to any of those present in the puzzle already. Task 4 Standard searching algorithms Issues: The learners need to be aware that both searching methods are used and have their place. Regardless of the algorithm used, the learners need to be aware (it's a common mistake) that the algorithm must allow for a condition where the search is over but the item is not found. The choice of the searching algorithms depends on the data that needs to be searched. The data that is unsorted will have to be searched in a linear, no-stone-unturned-until-found, door-to-door [picture of travelling salesperson/policeman or another suitable analogy for someone visiting every single house on a street]. This is because we don't know enough about the data to use any shortcuts. We can say that unsorted data is a poorer quality than sorted as the linear search is inefficient and processor intensive. However, storing data in unsorted state works better for weaker processors that might be overwhelmed by the process of simultaneously recording new data and sorting it.

Binary search is much more efficient as we need to look at the fewer items before we find the one we need. How is that achieved?

When booking into this hotel, you make it to your floor and this sign is the first thing you see. If you are looking for room 318, you will not have to search the entire floor, just the left side. To simplify the search for your room, the hotel conveniently numbered their rooms in sequence and placed the entrance to the floor in the middle, so that you can halve your search effort and time. You know by now that "binary" could be translated "one of the two options" - which is what the hotel gives you here - left or right. Imagine that if you do go left and about half way through that side of the floor, the corridor turns and branches out into further 2 halves with numbers "319-321" and "322-327". Which way will you turn? Binary search A hotel has 120 rooms located on 3 floors and 4 lifts/staircases. Design a floor plan (or signs for a given floor plan) for each of lifts/staircases. Assuming a person starts at lift 2. How many signs will they see before they find their room? Given pseudocode for a binary search, write it as (a) structured English; (b) code in your preferred high level language Linear search Given pseudocode for a linear search, write it as (a) structured English; (b) code in your preferred high level language

Task 6 Sorting and searching could end up being quite dry unless there is a visual element to them. There are many visualisations of the searching and sorting algorithms available on the internet, such as the one at http://www.sorting-algorithms.com. You will find that learners understand the algorithms better if they also can plot the results using a language with graphics abilities, eg Scratch/BYOB/Snap/AppInventor/Python/Basic, etc. The tasks would involve generating a random list of numbers and then applying an algorithm to it. Provided is an example of visualising a list in Scratch 2.0, using abstraction via a procedure. This procedure uses the stamp feature (which imprints the copy of the sprite s costume onto the Stage. The sprite s costume should be a smallish square (although, most symmetric shapes should work, as well). Learners should be given an opportunity to implement just the plotting of a list via the provided example and then they can design. For the extension activity, here is an example of using Python Turtle to do a visualisation of the Insertion Sort.

import turtle; from random import sample, choice; import time COLOURS = ["firebrick", "dark goldenrod", "sienna", "chartreuse4", "DeepSkyBlue3", "medium violet red", "red4", "saddle brown", "dark olive green", "spring green", "cadet blue", "deep pink"] screen = turtle.screen() t = turtle.turtle(); t.speed(0); t.width(10) def draw_col(x, y): t.penup() t.goto(x, 0) t.pendown() t.setheading(90) t.forward(y) def draw_sort(s): for i in s: draw_col(s.index(i)*15, i) def insertion_sort(s=sample(range(100), 10)): starttime = time.time() print("insertion sort") print(s) for i in range(1, len(s)): val = s[i] j = i - 1 while (j >= 0) and (s[j] > val): s[j+1] = s[j] j = j - 1

s[j+1] = val t.pencolor(colours.pop()) draw_sort(s) endtime = time.time() - starttime print ("Time taken: " + str(endtime) + " seconds") return s def quick_sort(s=sample(range(100), 10)): starttime = time.time() print(s) less = [] equal = [] greater = [] if len(s) > 1: pivot = s[0] for x in s: if x < pivot: less.append(x) if x == pivot: equal.append(x) if x > pivot: greater.append(x) print(less+equal+greater) return quick_sort(less)+equal+quick_sort(greater) else: endtime = time.time() - starttime print (endtime) return s

if name == " main ": print(insertion_sort()) #print("quick sort") #s = quick_sort() #print(s) screen.exitonclick() Task 7 Pseudocode, flow charts and structured English are used to describe the code before it is created. They are language-agnostic meaning pseudocode doesn t contain any references to any specific languages and in fact, the choice of the language used to do a program happens after the pseudocode is complete. The knowledge of pseudocode is needed for both exams and controlled assessment task submissions. Learners should be fluent in converting problems between the 3 techniques (and, of course to an actual code of a language like Python or JavaScript). This exercise asks pupils to create a dictionary a Rosetta Stone. We d like to know your view on the resources we produce. By clicking on the Like or Dislike button you can help us to ensure that our resources work for you. When the email template pops up please add additional comments if you wish and then just click Send. Thank you. If you do not currently offer this OCR qualification but would like to do so, please complete the Expression of Interest Form which can be found here: www.ocr.org.uk/expression-of-interest OCR Resources: the small print OCR s resources are provided to support the teaching of OCR specifications, but in no way constitute an endorsed teaching method that is required by the Board, and the decision to use them lies with the individual teacher. Whilst every effort is made to ensure the accuracy of the content, OCR cannot be held responsible for any errors or omissions within these resources. We update our resources on a regular basis, so please check the OCR website to ensure you have the most up to date version. OCR 2015 - This resource may be freely copied and distributed, as long as the OCR logo and this message remain intact and OCR is acknowledged as the originator of this work. OCR acknowledges the use of the following content: Maths and English icons: Air0ne/Shutterstock.com, Thumbs up and down icons: alexwhite/shutterstock.com Please get in touch if you want to discuss the accessibility of resources we offer to support delivery of our qualifications: resources.feedback@ocr.org.uk