GCSE Computer Science Component 02

Similar documents
HASTINGS HIGH SCHOOL

GCSE Computer Science for OCR Overview Scheme of Work

Autumn 1 Autumn 2 Spring 1 Spring 2 Summer 1 Summer 2. networks. environmental concerns. Knowledge and skills covered: Knowledge and skills covered:

OCR J276 GCSE Computer Science

Switching to AQA from OCR

OCR J276 (9-1) GCSE Computer Science

OCR GCSE (9-1) Computer Science J276 Accompanying Instructional Document

Year 10 OCR GCSE Computer Science (9-1)

Edexcel GCSE in Computer Science Microsoft IT Academy Mapping

National 5 Computing Science Software Design & Development

Switching to AQA from Edexcel

2nd Paragraph should make a point (could be an advantage or disadvantage) and explain the point fully giving an example where necessary.

Computing 1: Computer Systems

GCSE Computing. Revision Pack TWO. Data Representation Questions. Name: /113. Attempt One % Attempt Two % Attempt Three %

Teaching KS3 Computing. Session 3 Theory: More on binary and representing text Practical: Introducing IF

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming

Variables and Data Representation

The type of all data used in a C++ program must be specified

GCSE Computer Science Booster Pack

Decisions, Decisions. Testing, testing C H A P T E R 7

OCR GCSE Computing Learning Grids H/W

Dec Hex Bin ORG ; ZERO. Introduction To Computing

Text Input and Conditionals

Example 1: Denary = 1. Answer: Binary = (1 * 1) = 1. Example 2: Denary = 3. Answer: Binary = (1 * 1) + (2 * 1) = 3

Computer Systems. IGCSE OCR AQA Edexcel Understand the term. embedded system and how an Purpose of embedded system

Objectives. Connecting with Computer Science 2

AQA GCSE Computer Science PLC

Department Curriculum and Assessment Outline

Computer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2

Memory Addressing, Binary, and Hexadecimal Review

GCSE (9 1) Computer Science J276/02 Computational thinking, algorithms and programming Sample Question Paper. Specimen

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Bits and Bytes and Numbers

Data Representation 1

The type of all data used in a C (or C++) program must be specified

TABLE OF CONTENTS 2 CHAPTER 1 3 CHAPTER 2 4 CHAPTER 3 5 CHAPTER 4. Algorithm Design & Problem Solving. Data Representation.

Course Schedule. CS 221 Computer Architecture. Week 3: Plan. I. Hexadecimals and Character Representations. Hexadecimal Representation

BB4W. KS3 Programming Workbook INTRODUCTION TO. BBC BASIC for Windows. Name: Class:

Fundamentals. Fundamentals. Fundamentals. We build up instructions from three types of materials

Part III Appendices 165

CC411: Introduction To Microprocessors

The x86 Microprocessors. Introduction. The 80x86 Microprocessors. 1.1 Assembly Language

TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA

Learning the Binary System

CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch

umber Systems bit nibble byte word binary decimal

CS 100 Spring Lecture Notes 3/8/05 Review for Exam 2

Definition: A data structure is a way of organizing data in a computer so that it can be used efficiently.

[301] Bits and Memory. Tyler Caraza-Harter

OCR J276 GCSE Computer Science

Chapter 2. Data Representation in Computer Systems

To become familiar with array manipulation, searching, and sorting.

Binary. Hexadecimal BINARY CODED DECIMAL

COMPUTING SUBJECT KNOWLEDGE AUDIT

Topic Notes: Bits and Bytes and Numbers

Chapter 8 Algorithms 1

Topic Notes: Bits and Bytes and Numbers

15110 PRINCIPLES OF COMPUTING SAMPLE EXAM 2

Excel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller

History of Computing. Ahmed Sallam 11/28/2014 1

Intro to Algorithms. Professor Kevin Gold

C++ Data Types. 1 Simple C++ Data Types 2. 3 Numeric Types Integers (whole numbers) Decimal Numbers... 5

Basic data types. Building blocks of computation

If Statements, For Loops, Functions

Discussion. Why do we use Base 10?

These are notes for the third lecture; if statements and loops.

Intro. Scheme Basics. scm> 5 5. scm>

XP: Backup Your Important Files for Safety

Lecture 1: What is a computer?

C H A P T E R 1. Introduction to Computers and Programming

Outline. Parts 1 to 3 introduce and sketch out the ideas of OOP. Part 5 deals with these ideas in closer detail.

Excel Basics: Working with Spreadsheets

Review: Exam 1. Your First C++ Program. Declaration Statements. Tells the compiler. Examples of declaration statements

Beyond Base 10: Non-decimal Based Number Systems

9/3/2015. Data Representation II. 2.4 Signed Integer Representation. 2.4 Signed Integer Representation

Stonelaw High School. Computing Science. BGE - Computer Systems

Kinds Of Data CHAPTER 3 DATA REPRESENTATION. Numbers Are Different! Positional Number Systems. Text. Numbers. Other

Final Labs and Tutors

data within a computer system are stored in one of 2 physical states (hence the use of binary digits)

An Introduction to Python (TEJ3M & TEJ4M)

St. Benedict s High School. Computing Science. Software Design & Development. (Part 2 Computer Architecture) National 5

Mobile Computing Professor Pushpendra Singh Indraprastha Institute of Information Technology Delhi Java Basics Lecture 02

Computing and compilers

8 Algorithms 8.1. Foundations of Computer Science Cengage Learning

The Building Blocks: Binary Numbers, Boolean Logic, and Gates. Purpose of Chapter. External Representation of Information.

Program Fundamentals

Data Representation From 0s and 1s to images CPSC 101

The Big Python Guide

8/16/12. Computer Organization. Architecture. Computer Organization. Computer Basics

IB Computer Science Topic.2-

VARIABLES. Aim Understanding how computer programs store values, and how they are accessed and used in computer programs.

What did we talk about last time? Examples switch statements

CS 115 Lecture 8. Selection: the if statement. Neil Moore

Contents. Slide Set 1. About these slides. Outline of Slide Set 1. Typographical conventions: Italics. Typographical conventions. About these slides

Computer Components. Software{ User Programs. Operating System. Hardware

Standard File Formats

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 1: Basic Concepts. Chapter Overview. Welcome to Assembly Language

AQ A G C S E 9-1 C O M P U T E R S C I E N C E R E V I S I O N G U I D E M U R P H Y V I A A M A Z O N

Exercise: Using Numbers

CSC 101: Lab Manual#9 Machine Language and the CPU (largely based on the work of Prof. William Turkett) Lab due date: 5:00pm, day after lab session

CS112 Lecture: Primitive Types, Operators, Strings

Transcription:

GCSE Computer Science Component 02 Revision

Computational Thinking ABSTRACTION Making a problem simpler by removing unnecessary details. This is important when coding as it: Makes it easier to code! Means less time is wasted on the unnecessary details. Means the final product will use less memory and processor power. e.g. we are making a system to track a pupil s attendance in school: DETAILS WE MIGHT KEEP IN Pupil names Whether they were in or not on a certain day Days of the week Holidays UNNECESSARY DETAILS WE WOULD LEAVE OUT Pupil eye colour Medical records Behaviour points Phone number DECOMPOSITION Breaking a difficult problem down into smaller and smaller sub problems until they are easy to solve. We use this in programming to break a project down until we can code each section with one function. Here is a problem decomposition diagram for an Endless Runner style game.

ALGORITHMIC THINKING The spec says you need to think in algorithms don t worry! You have been learning this since you started to learn how to code. You will need to be able to understand and write flow diagrams and pseudocode. FLOW DIAGRAM SYMBOLS START / STOP PROCESS DECISION INPUT / OUTPUT SUBROUTINE The good news is that when writing pseudocode there isn t a right or wrong. You can write anything that looks a bit like code and a bit like English. You just need to show the processes you would use when you write actual code. The exam board have a standardised format for the pseudocode they will use. This is available in the specification (appendix 5f) which can be downloaded from the exam board s website or you can ask your teacher. Linear Search Used to search a list or array for a certain item and returns the index. Can be used on unsorted lists. Checks each item in turn one-by-one until the item is found. If the item isn t found a value of 1 is returned. Not efficient for large lists although you might get lucky and the item could be in the first few you check. start here...go through these to the end checking for a match... stop Value Index 3 15 2 8 7 1 14 38 10 6 0 1 2 3 4 5 6 7 8 9

Binary Search The array must be sorted. A mid point is found and a logical test is made to decide whether the item is less than, greater than or equal to the mid point. If less than or greater than, half the array is discounted. This repeats until the mid point = the item found. Uses three pointers low, mid and high. Much faster for large lists than linear search but array must be sorted first. Example: searching for 7 1 7 9 12 13 18 22 25 28 30 0 1 2 3 4 5 6 7 8 9 low high The mid-point is worked out to be index 5. In this example we can see that 7 < 18 so we discard the high half of the array by setting the high pointer to be mid 1 and keeping the low pointer the same. 1 7 9 12 13 18 22 25 28 30 0 1 2 3 4 5 6 7 8 9 low mid high The mid-point is now worked out to be index 2. We can see that 7 < 9 so we set high to be mid 1 and keep the low pointer the same again. 1 7 9 12 13 18 22 25 28 30 0 1 2 3 4 5 6 7 8 9 low mid high The mid-point is worked out to be index 2. This time the mid-point is equal to the item searched for so we return the index value which is 1.

Bubble Sort A bubble sort involves looping through every item in an array. Each item is compared to the one to its right. If they are in the wrong order they swap. A variable needs to be used to store whether or not there were any swaps in a pass. When there are no swaps the algorithm ends. Each pass the largest value will bubble to the right. This means it is not necessary to check this number again. Bubble sort is a very slow sort and there is no reason to use it other than for academic purposes. The only advantage is that some may find it slightly easier to implement than some other sorts. 10 1 8 3 7 1 and 10 compared and swapped (swap set to true) 1 10 8 3 7 10 and 8 compared and swapped 1 8 10 3 7 10 and 3 compared and swapped 1 8 3 10 7 10 and 7 compared and swapped - first pass complete 1 8 3 7 10 1 and 8 compared - not swapped 1 8 3 7 10 8 and 3 compared and swapped (swap = true) 1 3 8 7 10 7 and 8 swapped. No need to check 10 again. Pass complete. 1 3 7 8 10 1 and 3 compared. 1 3 7 8 10 3 and 7 compared. No need to check 8 and 10. No swaps so end. Insertion Sort In an insertion sort we loop through the array from left to right. For each index, we loop back to the left comparing each value as we go. If the value is greater than the index we shift it right. This continues until we find the correct insertion point and the index in placed in the correct spot. One iteration from left to right is enough to fully sort the array. Insertion sort is generally much faster than bubble sort. 5 2 4 6 1 2 5 4 6 1 2 4 5 6 1 For each index of the array the algorithm loops back to the left to find the insertion point. Any item which is bigger than the index is shunted to the right until the index is in the correct place. 1 2 4 5 6

Merge Sort The array is divided in half over and over until each subset is 1 big. A merge algorithm is performed on each pair of subsets until there is one, combined, sorted subset left. Merge sort is significantly faster for large arrays than insertion or bubble sort. The original array is split into smaller and smaller arrays until each array has a length of one. The merge function is then called on each pair of arrays. This happens over and over until one, sorted array remains. Don t forget you can play around with these algorithms at http://www.learncomputing.org/ algorithms.php

Programming Techniques Variable - points to a named section of memory where a value is stored. The value can change during the program s execution. Constant - points to a named section of memory where a value is stored. The value cannot change during the program s execution. Assignment the process of storing a value in a variable / constant. Variables are given a data type. This sets the size of the storage location in memory and dictates what values are allowed to be stored there. DATA TYPE ALTERNATE NAMES DESCRIPTION Integer A whole number e.g. 7 Real Float, single, double, decimal A number with a decimal point e.g. 7.45 Character char One ASCII character e.g. R String A word or sentence made up of multiple characters. Stored as a special read-only array of characters. Boolean bool Has only two possible values true or false CASTING The process of converting one data type to another. See below example of casting to an integer and string. OCR PYTHON C#

Sequence, Selection and Iteration Sequence - instructions are executed in order from top to bottom until told to stop. This is the basic way that programs work. Selection - the program will branch to a different section depending on the result of a comparison. In simple terms this is an IF statement. Iteration a section of the program is repeated either a certain number of times or until a condition is no longer true. In simple terms this will be either a FOR loop or a WHILE loop. SEQUENCE AND SELECTION EXAMPLES OCR PYTHON C# ITERATION EXAMPLES OCR PYTHON C#

Arrays An array is a series of storage locations in memory that are named under one identifier. Each location is given an index beginning with zero. Those of you who have studied Python should know that arrays do not exist in this language. Python uses Lists instead which are similar. At GCSE level it is ok to assume that lists and arrays are the same thing. Arrays can be one-dimensional (one row) or two-dimensional (many rows like a grid). 1D ARRAYS Animals = Dog Horse Fish Cow Sheep 0 1 2 3 4 The following examples show how to declare and assign the array above. It then shows how to iterate through the array and print out each value. OCR PYTHON C#

2D ARRAYS 0 1 2 foods = 0 Beef Turkey Chicken 1 Bread Rice Dog Pasta 2 Carrot Leek Onion The following examples show how to declare and assign the 2D array above. Notice the indexes start in the top left! It then shows how to iterate through the array and print out each value. If using Python then technically you are creating a list of lists but don t worry about it at GCSE level. OCR PYTHON C#

String Handling Get the length of a string. OCR PYTHON C# Get part of a string. This example will print Fred. OCR PYTHON C# Convert to upper case and lower case letters. Useful for validations. OCR PYTHON C#

Convert to ASCII and back again. OCR PYTHON C# File Handling Remember when using files you have to open them in either read, write or append mode. You have to open the file, do your reading or writing, then close the file. The following examples will read every line from a file and write a line to a file. OCR PYTHON C#

Procedures and Functions A procedure is a named section of code that can be called multiple times. It can take any number of values as parameters but it does not return a value. OCR PYTHON C# A function is a named section of code that can be called multiple times and returns a value. It can take any number of values as parameters. OCR PYTHON C# Operator Meaning Operator Meaning Operator Meaning == Equal to!= Not equal to < Less than <= Less than or * Multiply / Divide - Subtract + Add AND Logical AND (&&) OR Logical OR ( ) NOT Logical NOT (!) > Greater than >= Greater than or equal to MOD DIV ^ Get the remainder of a division Get the whole number part of a division Power of

Structured Query Language (SQL) SQL is used to create and search databases. At GCSE level you only need to know how to search. You might be given a data table like the one above and be expected to state the results of some SQL queries. SQL Query Value(s) Returned SELECT Strength FROM Heroes WHERE Hero Name = Apocalypse 50 SELECT * FROM Heroes WHERE Strength > 40 SELECT Hero Name FROM Heroes WHERE Intelligence > 6 AND Speed > 7 Gives all the fields from Apocalypse and Dr Doom Apocalypse SELECT Hero Name FROM Heroes WHERE Intelligence > 6 OR Speed > 7 Apocalypse, Black Panther, Dr Doom, Dr Octopus, The Beast Wildcards: * can be used to mean all fields should be returned or it could mean insert any number of letters. % means insert any one letter. LIKE: can be used to find values that are similar to the one in the statement.

Producing Robust Programs Anticipating Misuse When you design a system you should always assume that the worst will happen. Either somebody will accidentally do something silly to break it or, more likely, a malicious user will deliberately destroy it. It s important to build in safeguards to protect yourself. Input Sanitization Whenever there are inputs to your system -for example in a form on a webpage you should assume that somebody will try to enter malicious code. SQL injection is an example of this. To prevent this you should sanitize the input: Strip out special characters like! $ Use prepared statements that stop a hacker manipulating the SQL string. Validation This tries to ensure a user s input is reasonable. Different types: Length check: test if the input isn t too long Format check: test if the input is in the correct format e.g. a date. Presence check: make sure something has been entered. Range check: test that a number entered is within a certain range. Authentication The process or action of verifying the identity of a user or process. This is what happens when you log into a system.

Maintainability This refers to making your programs easy to debug, easy to work on in the future and easy to work on in a team. Comments Adding comments to your code is a sensible way to describe what your code does. This means that when you come back to it later you can remember what it all does. It also helps when other people work on your code. Indentation If you indent lines then it makes the code easier to read. Those of you that have learned Python know that this is required to get the code to work! Those of you that have studied C# will know that Visual Studio indents the code for you. Students of other languages are not so lucky! Testing Iterative This is testing as you code and is completed by the developer. You should make sure you test each line of code as you develop your program. Final / Terminal This testing is done when the program has been completed. Often, it will be done by a team of testers who will try to test all the inputs and outputs of a system to make sure everything works as intended. Syntax Error An error when the rules of the language have been broken. This could be anything from a misspelled work or a comma out of place or some other punctuation. Logic Error When all the rules of the language have been followed but the programmer has made some other mistake that prevents the program from running as expected.

Computational Logic AND OR NOT You ll need to be able to recognise the three logic gate symbols above and be able to create relevant truth tables from any two of them combined. Remember, when creating a truth table, you just need to work out every possible combination of inputs each one could be either 0 or 1. A B Q Creating a truth table from an AND gate. 0 0 0 0 1 0 1 0 0 1 1 1 A B Q Creating a truth table from an OR gate. 0 0 0 0 1 1 1 0 1 1 1 1 Creating a truth table from a NOT gate. A Q 0 1 1 0

Here is are two examples of combining two gates together. In the exam you could be asked to combine AND with OR, AND with NOT or OR with NOT. Make sure you know how to do all the tables! A B NOT (a AND b) 0 0 1 0 1 0 1 0 0 1 1 0 A B C D Q 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 1 1 1 0 1 0 0 0 1 1 0 1 0 1 1 1 0 0 1 1 1 1 1 1 1

Translators HIGH LEVEL CODE High Level Languages These languages use English sounding words that make it easier to code with. The language you learned on the course (e.g. Python, C#) is a high level language. It must be translated into machine code before it can be executed either by a compiler or an interpreter. COMPILER Translates the program all at once. If there are any errors the program won t run and all the errors will be displayed at once. INTERPRETER Translates the program one line at a time. If there is an error, the program stops and it is reported. HIGH LEVEL LANGUAGES ARE TRANSLATED INTO MACHINE CODE WITH EITHER A COMPILER OR AN INTERPRETER LOW LEVEL CODE Assembly Language This is a low level language that uses mnemonics to represent machine code statements. It has to be translated into machine code using an assembler. ASSEMBLY IS TRANSLATED INTO MACHINE CODE WITH AN ASSEMBLER Machine Code This is the lowest level language and is the only code a CPU can understand. It is written in binary (0s and 1s) and is hard for a human to work with. All code must be translated into machine code before it can be run.

IDEs The Integrated Developer Environment is the program you use to write your code in. An IDE has lots of features that make it easier to develop software. The ones the exam board want you to know about are: Editor This is simply the text editor that you type your code in. It might have some useful features to help you: for example IntelliSense can remind you of the commands. Error Diagnostics This is the part of the IDE that tells you about errors. Once the program has been run it will give you a list of errors. Some IDEs use code highlighting to show you errors as you are typing. Run-Time Environment A testing environment that lets you run your code and track the values of variables without fully compiling it into an executable file. Translators Converts the program into an executable file. This means it is in machine code and can run on a CPU. There are two types: compiler and interpreter (see previous page).

Data Representation Why is binary used? Binary is used as it only has two possible values 0 and 1. This is to represent the transistor switches that exist in the CPU which can either be ON or OFF. The CPU can only work with binary so all code has to be translated into binary machine code. Converting to and from binary The key to converting to and from binary is writing out the column headings first. Always remember the smallest number goes on the right! 128 64 32 16 8 4 2 1 0 0 1 1 0 1 1 0 32 + 16 + 4 + 2 = 54 The best place to practice binary conversions is at www.learncomputing.org/quiz.php Why is hexadecimal used? Binary can be difficult to work with and it is easy to make a mistake. Hexadecimal is less prone to errors and it is very easy to convert between binary and hex so lots of computer scientists prefer using it. You can see hex references in colour codes and memory addresses. Converting to and from hex The key to converting to and from hex is writing out the column headings and the numbers 1-15 with their hex equivalent. Do this in the exam! This will prevent you making any mistakes and you won t lose any marks. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 2 3 4 5 6 7 8 9 A B C D E F You can also practice hex conversions at: www.learncomputing.org/quiz.php You will need to be proficient at: Converting from denary to binary and back again Converting from denary to hexadecimal and back again Converting from binary to hexadecimal and back again Adding two binary numbers Binary shifts

Units of Storage Unit Number of Bytes Bit 1/8 Nibble 1/2 Byte 1 Kilobyte 1,000 Megabyte 1,000,000 Gigabyte 1,000,000,000 Terabyte 1,000,000,000,000 Petabyte 1,000,000,000,000,000 A byte has 8 bits e.g. 10011100 Sometimes you see a kilobyte listed as 1024 bytes. Keep it simple for your GCSEs and use the numbers opposite. The exam board will mark these right! Characters Characters like letters, numbers and symbols need to be stored in binary just like everything else in a computer. The way this is done is simply just to give each letter or symbol a unique binary number. Of course, there are lots of different ways this could be done. Each one is called a character set. The three varieties you need to know are ASCII, extended ASCII and Unicode. ASCII The American Standard Code for Information Interchange. This character set uses 7 bits to represent characters meaning there are 128 possible combinations. This is only enough to cover English letters. This is the ASCII table. There are 128 characters that are each given a unique 7-bit binary number.

EXTENDED ASCII This character set uses one more bit than the original ASCII table. This means there are 256 possible combinations so more characters can be represented. UNICODE ASCII was OK for English speakers but aren t enough combinations to allow all the different alphabets used around the world. For example, there are over 5,000 symbols in common usage in the Chinese alphabet so we need a much better system. Unicode uses up to 32-bits for each character meaning there can be 4,294,967,296 possible characters. This is easily enough for all alphabets in the world plus all the scientific and maths symbols plus room to spare for any more we might need in the future. You can see the whole table at: https://unicode-table.com/en/ Note: The 127 ASCII characters have the same binary number in Unicode. This means Unicode is fully backwardly compatible with ASCII. Sound Sound needs to be converted to binary to be used and stored in a computer system. To turn sound into binary we need to sample it. An analogue sound wave is taken and the amplitude (height) of the wave is measured at regular intervals. This is converted into a binary number. SAMPLING FREQUENCY The more often the amplitude is measured, the better the quality of the sound. Increasing the sampling frequency makes the sample more true to the original but increases the file size. BIT RATE / SAMPLING DEPTH This refers to the number of bits of data taken during each sample. The higher the bit rate, the closer to the original the sample will be but the file size will be higher.

Images Images need to be converted into binary to be stored in a computer. A common way of doing this is using a bitmap. Bitmap images are made up of pixels. For each pixel, a binary number is stored that represents a colour. Resolution: The number of pixel in the image. The more pixels there are, the higher the quality of the image but the higher the file size. Colour depth: The number of bits used to store the colour for each pixel. The higher the colour depth, the more colours can be used in the picture but the file size will be higher. Metadata: This is data that goes at the start of an image file that tells you all about the file. It might say the resolution, the colour depth, the file format, where the picture was taken, information about the camera and many other things. Don t forget you can play around with bitmap images at www.learncomputing.org/bitmap.php Compression Often, we might want to make a file smaller. This could be: To save storage space To transmit it quicker (e.g. over the internet) Compressing a file will make it smaller. There are two types: LOSSY COMPRESSION Makes a file smaller but at the cost of losing some of the data. This type of compression is used when it doesn't matter if a little bit of data is lost for example in a picture file, sound file or video file. LOSSLESS COMPRESSION Makes a file smaller but without losing any data. This isn t as effective as lossless compression but can be used when it wouldn t be appropriate to lose any data. For example, you wouldn t want to compress a text file and lose some letter or words so you might use lossless compression for this.