A-level Computing/AQA/Print version/Unit 1
Contents
- 1 Authors
- 2 Book Overview
- 3 Unit 1 - Summary
- 4 Problem solving
- 4.1 Introduction to principles of computation
- 4.2 Decomposition
- 4.3 Pattern recognition
- 4.4 Pattern generalisation and abstraction
- 4.5 Algorithm design
- 4.6 Limits?
- 4.7 References
- 4.8 Stages of problem solving
- 4.9 Understand the problem
- 4.10 Define boundaries
- 4.11 Plan solution
- 4.12 Check solution
- 4.13 Top-down design and Step-wise refinement
- 4.14 Stages of problem solving
- 4.15 Understand the problem
- 4.16 Define boundaries
- 4.17 Plan solution
- 4.18 Check solution
- 4.19 Structure charts
- 4.20 Selection
- 4.21 Iteration
- 4.22 Decision tables
- 4.23 Finite state machines
- 4.24 Finite state machines
- 4.25 Algorithm design
- 4.26 Sequence
- 4.27 Assignment
- 4.28 Selection
- 4.29 Trace tables
- 4.30 Pseudo code
- 4.31 Structured English
- 4.32 Searching and sorting
- 4.33 Linear Search
- 4.34 Binary Search
- 5 Fundamentals of programming
- 5.1 Variables
- 5.2 Introduction
- 5.3 Variables
- 5.4 Notes
- 5.5 Comments
- 5.6 Python example
- 5.7 Inputs and outputs
- 5.8 Outputs
- 5.9 Inputs
- 5.10 Arithmetic operators
- 5.11 Why the funny symbols?
- 5.12 Addition
- 5.13 Subtraction
- 5.14 Multiplication
- 5.15 Division
- 5.16 Integer division
- 5.17 Remainder Division
- 5.18 Exponentiation
- 5.19 BODMAS
- 5.20 Built-in data types
- 5.21 Assignments
- 5.22 Constant definitions
- 5.23 Selection
- 5.24 IF Statement
- 5.25 Relational operators
- 5.26 Case Statement
- 5.27 Iteration
- 5.28 While Do
- 5.29 Do While Loop
- 5.30 For Loop
- 5.31 Loopy Loops (Nested Loop)
- 5.32 Built-in functions
- 5.33 Arithmetic functions
- 5.34 String handling functions
- 5.35 One-dimensional arrays
- 5.36 Uses
- 5.37 Functions and procedures
- 5.38 Declarations
- 5.39 Calls
- 5.40 Parameters (and Arguments)
- 5.41 Global and local variables
- 5.42 Two-dimensional arrays
- 5.43 Noughts and Crosses
- 5.44 User-defined data types
- 5.45 Enumerated
- 5.46 Records and Fields
- 5.47 File handling
- 5.48 Reading files
- 5.49 Writing files
- 5.50 CSV
- 5.51 File of records
- 5.52 Validation
- 5.53 Catching errors
- 5.54 The role of variables
- 5.55 Fundamentals of structured programming
- 5.55.1 Use procedures that execute a single task
- 5.55.2 Use procedures/functions with interfaces
- 5.55.3 Use sensible variable datatypes
- 5.55.4 Meaningful identifier names
- 5.55.5 Try to stick to one naming convention
- 5.55.6 Don't make your names too long
- 5.55.7 Indent your work
- 5.55.8 Use comments where necessary
- 5.56 The advantages of the structured approach
- 5.57 Modulo arithmetic
- 5.58 Logical bitwise operators
- 5.59 Programming
- 5.60 Set operators
- 5.61 Basic set understanding
- 5.62 Membership ∈ and its reverse ∉
- 5.63 Union ∪
- 5.64 Intersection ∩
- 5.65 Difference \
- 5.66 Proper Subsets ⊂
- 5.67 Subsets ⊆
- 6 Fundamentals of data representation
- 6.1 Bit patterns in a computer
- 6.2 Bits and Bytes
- 6.3 Minimum and Maximum Number vs. Number of Different Values
- 6.4 Denary, Binary and Hexadecimal number systems
- 6.5 Denary/Decimal
- 6.6 Hexadecimal
- 6.7 Binary arithmetic
- 6.8 Addition
- 6.9 Multiplication
- 6.10 Binary fractions
- 6.11 Binary Fractions - using Fixed Point notation
- 6.12 Two's complement
- 6.13 Binary Subtraction
- 6.14 Status register
- 6.15 Overflow
- 6.16 The most common flags
- 6.17 Information coding schemes
- 6.18 ASCII
- 6.19 ASCII
- 6.20 Unicode
- 6.21 Unicode
- 6.22 Error checking and correction
- 6.23 Parity bits
- 6.24 Hamming code
- 6.25 Checking if correct
- 6.26 Applying hamming code
- 6.27 Gray coding
- 6.28 Images
- 6.29 Bitmaps
- 6.30 Overview
- 6.31 Resolution
- 6.32 Colour Depth
- 6.33 Vectors
- 6.34 Comparison between vector and bitmaps
- 6.35 Sounds
- 6.36 Analogue and digital
- 6.37 Sampled sound
- 6.38 Sampling rate
- 6.39 Sampling resolution
- 6.40 File sizes
- 6.41 Sound compression
- 6.42 Lossless
- 6.43 Lossy
- 6.44 Nyquist-theorem
- 6.45 References
- 6.46 Sound synthesis
- 6.47 Computer Science. It aims to fit with the AQA GCE A-Level Computer Science 2015 Computer Science students have.
Accepted languages
A-Level Projects can be written in any language.
Old Specification
AS modules
- COMP1 - Problem Solving, Programming, Data Representation and Practical Exercise
- COMP2 - Computer Components, The Stored Program Concept and the Internet
A2 modules
- COMP3 - Problem Solving, Programming, Operating Systems, Databases and Networking
- COMP4 - The Computing Project. The tree shows the relationship between modules, showing data transfer between the models.
Let's take a look at a simple example of how this might be executed when representing the following code:
dim num1, num2 as integer sub calculateAverage() dim avg as integer inputNums() avg = average(num1, num2) outputAvg(avg) end sub function average(a,b) return (a + b) / 2 end function sub inputNums() Function countdown(a) return a - 1 End Function
Finite state machines, dependent
A searching algorithm looks for a given item in a given data structure. The algorithm used depends on how the data is structured.
Linear Search
Fundamentals of programming
- Selection
- Iteration
- Functions and Procedures
-:
1 module module1 2 sub main() 3 console.writeline("Hello there, my name is Peter and my age is 29") 4 console.writeline("6 * 6 = " & 6 * 6) 5 console.readline() 6 end sub 7:
you might be expecting both programs to print out:
Hello name you are age years old
But instead they say:
What friendly programs!
Let's break the VB.NET:
1 dim identifierName as integer 2 identifierName = 7 3 console.writeline("The value stored in identifierName is: " & identifierName)
Producing:
Let's break the Python)
- We create a temporary data store, a variable name called
nameand assign a value and as it's a string we better use speech marks1 - "Peter"
- We create a temporary data store, a variable name called
ageand assign. To add the integer variable we convert it to a string using the built-in string function and this ( Python we simply create it with a meaningful name.:
Notes
- 1.^ You get a choice in Python between using speech marks or apostrophes for strings, so
"Peter"and
'Peter'are the same. This is important to know if you start looking online for examples of Python code since some people will use speech marks whereas other people like to use apostrophes instead.)
Python example
# character, like this:
# this is a comment animal = "bunny" # initialise a variable with the string "bunny" print(animal) # this is another comment).:
Arithmetic operators.:
There is a second addition operator, "+=". It increments the variable on the left of the += by the amount indicated on the right. Examples:
It also works with Strings as a concatenation operator. Examples:
Subtraction
This subtracts two numbers, and is denoted by the "-" symbol. Examples:
Multiplication
This multiplies two numbers, and is denoted by the "*" symbol. Examples:
Division
There are more types of division than the one denoted by the "/" symbol. There is also integer division and remainder division.
Normal
This is the most commonly used form of division and is denoted by the "/" operator. Examples:
Integer division
This divides two numbers, and gives the result without the remainder if the quotient is a decimal. Examples:
Remainder Division
This divides two numbers, and gives the result's remainder if the quotient is a decimal. This is denoted by the operator "Mod" in VB.NET and "mod" in Python. Examples:
Exponentiation
You have probably learnt about the order of operations in maths. BODMAS also applies to computer calculations. This means that when calculating a sum, the program will calculate:
- Brackets
- Order (powers n^2 etc)
- Division
- Multiplication
- Addition
- Subtraction
The Else part is optional, you can just ignore the commoner! (and dump the Else)
You might also want to test multiple things in the If statement. For example:
Relational operators: (Nested Loop) (and Arguments)
Parameters allow you to pass values to the procedures and functions that you declare, you can pass all sorts of data:
1 Module Glocals 2 Dim number1 as integer = 123 3 4 Sub Main() 5 console.writeline(number1) 6 printLocalNumber() 7 printGlobalNumber() 8 End Sub 9 10 Sub printLocalNumber 11 Dim number1 as integer = 234 12 console.writeline(number1) 13 End Sub 14 15 Sub printGlobalNumber 16 console.writeline(number1) 17 End Sub 18.
Writing files
As well as reading files it's important that we can write to files.
When stored as (.csv), each line of a file is a data record. Each record consists of one or more fields, separated by commas. You should be able to move data between a 2d array and a csv file. The following code gives you an example of how to do this.: call
Basic set understanding
Sets describe collections of things or values, such as numbers, animals or people.
In a set, each value occurs only once. For example, the value fox will occur only once in the set of animals. Just as the value 3 occurs only once in the element of all natural numbers, N.
The cardinality of a set refers to the number of elements it contains.
An empty set is written ∅ and its cardinality is 0.
Sets may be finite or infinite. For example, the set of people currently alive in the world will be finite, but the set of N is infinite.
A set may be countable or uncountable. A countable set is a set, whose elements can be matched with the set of natural numbers. In other words, it is possible to count the elements one-by-one. If a set is finite, it will always be countable. The best example of an uncountable set is R. It is impossible to match each element of R with an element of N. This is because there are not enough elements in N to match each one with an element of R.
Membership ∈ and its reverse ∉
x ∈ S, x is an element of S.
Examples:
- x ∈ ℕ, meaning that x is an element of the set of natural numbers. For example, 3 ∈ ℕ. Whereas 3.5 ∉ ℕ
- x ∈ Q, meaning that x is an element of the set of rational numbers. Whereas pi ∉ Q
- x ∈ WorkingDays, meaning that x is an element of the set of all WorkingDays. For example, Monday ∈ WorkingDays. Whereas Saturday ∉ WorkingDays
- x ∈ WeekendDays, meaning that x is an element of the set of all WeekendDays. For example, Saturday ∈ WeekendDays. Whereas Monday ∉ WeekendDays
Union ∪
A ∪ B, meaning that all elements of the set A form a union with all of the elements in set B. This is a set comprehension, since this generates a new set.
Examples:
- Q ∪ Irrational Number Set, meaning that all numbers in the set of rational numbers form a union with the set of all irrational numbers. This set comprehension generates the set of real numbers.
- WorkingDays ∪ WeekendDays, meaning that all of the working days (elements of WorkingDays) form a union with weekend days (elements of WeekendDays). This set comprehension generates the set of WeekDays.
- {1, 2} ∪ {2,3,4} = {1,2,3,4} (notice that only once instance of 2 is in the resulting set)
- {1, 2, green} ∪ {red, white, green}={1, 2, red, white, green}
- {1, 2} ∪ {1, 2} = {1, 2}
Intersection ∩
A ∩ B, meaning that the set A and set B form an intersection. The generated set will be ∅, if the two sets share no elements.
Examples:
Let A be the set of numbers which are divisible by 3 and B the set of numbers divisible by 4.
- A ∩ B, meaning that A and B form an intersection, which generates a set, which contains all of the numbers divisible by 3 and 4.
- WorkingDays ∩ WeekendDays, meaning that WorkingDays and WeekendDays form an intersection, which is ∅
Now let A be the set of all A-level students who take computer science and B the set of all A-level students who take mathematics.
- A ∩ B, meaning that A and B form an intersection, which generates a set, which contains all students who take both computer science and mathematics.
- {1, 2, 3} ∩ {2, 3, 4} = {2, 3}
- {1, 2, 3} ∩ {bear,hen,squirrel} = Ø (this means an empty set)
- {cat, dog, canary} ∩ {wolf, canary, whale, cat} = {cat, canary}
Difference \
A \ B, meaning that the set A and set B form a set difference. This will generate a set, which contains the elements of A, which are NOT also in B.
Examples:
- R \ Q, meaning that R and Q form a set difference. This will generate the set of irrational numbers.
Let A be the set of all A-level students who take computer science and B the set of all A-level students who take mathematics.
- A \ B, meaning that A and B form a set difference. This will generate the set of all computer science students, who do not also take mathematics.
- {1, 2, 3} ∩ {2, 3, 4} = {2, 3}
- {1, 2, 3} ∩ {bear,hen,squirrel} = Ø (this means an empty set)
- {cat, dog, canary} ∩ {wolf, canary, whale, cat} = {cat, canary}
Proper Subsets ⊂
S ⊂ T, meaning that S is a proper subset of T, such that all elements in S are also elements of T. However, there will need to be at least one element in T, which is not in S.
Examples:
- N ⊂ Z, meaning that the set of natural numbers is a proper subset of the set of integers. In other words, all natural numbers are also integers. There are some elements in Z, which are not in N - these are the negative integers.
- Z ⊂ Q, meaning that the set of integers is a proper subset of the set of rational numbers. In other words, all integers are also rational numbers. But there are rational numbers which are not integers.
Subsets ⊆
A ⊆ B, meaning that A forms a subset of B. In other words, A could be identical to B, but does not have to be!
Examples:
Let A be the set of all students in 6th form and B the set of all students taking computer science.
- A ⊆ B, meaning that A forms a subset of B. In other words, all students in the 6th form could be taking computer science. In which case the two sets would be the same, but they may not be!
Now let A be all of the students present in school and B the set of students currently in the assembly hall.
- A ⊆ B, meaning that A forms a subset of B. In other words, all students currently in present in school may all be located in the assembly hall, but they may not be!
Fundamentals of data representation
Bit patterns in a computer
Bits and Bytes,/binary patterns for binary digits:
Example
2 bits can be configured in 22 = 4 different ways. 3 bits can be configured in 23 = 8 different ways. - using Fixed Point notation (see below)....