AQA Computer Science - Paper 1
PROGRAMMING
Algorithm
A methodical, logical rule or procedure that guarantees solving a particular problem.
Difference between algorithms and computer programs
Computer programs are implementations of algorithms
Decomposition
The process of breaking down larger problems into smaller more manageable sub
problems
Abstraction
The removal of unnecessary information to make a problem easier to understand
Steps to answer : Describe this algorithm in terms of inputs and outputs
1) draw an input and output table that shows the inputs and outputs
2) State the inputs, what data structure they are, their datatype and its name
3) State the outputs, what data structure they are, their datatype, where its going and
its name
Steps to answer : why one algorithm is more efficient than another
1) Compare how many calculations are taking place
2) Compare the number of complex structures (Iteration and Selection)
3) And therefore it would run in less time
DO NOT SAY THERE ARE FEWER LINES OF CODES CAUSE THAT IS WRONG
AND JUST STUPID
Flowcharts
A graphical representation of the steps in a process; details all of the elements in a
process and the sequence in which these elements occur. A form of algorithm
Oval
Shows the start and end of a flowchart
Rectangle
A process, i.e addition, division
Parallelogram
An input or output
Diamond
A decision
Arrows
Shows the flow of information
Linear Search
a method for finding a target value within a list. It sequentially checks each element
of the list for the target value until a match is found or until all the elements have
been searched. Works even if the list is unsorted.
linear search advantages
Simple, Works on unsorted data
Linear search disadvantages
Not efficient in very long lists
Binary Search
Looking for an item in an already sorted list by eliminating large portions of the data
on each comparison. Continuously divides the list in 2 discarding the set which has
numbers greater than the number being searched.
,Binary search advantages
Extremely efficient
Binary search disadvantages
Doesn't work on unsorted data
Bubble Sort
A sort in which the first two items to be sorted are examined and exchanged if
necessary to place them in the specified order; the second item is then compared
with the third (exchanging them if required), the third is compared with the fourth,
and the process is repeated until all pairs have been examined and all items are in
the proper sequence.
Bubble sort advantages
- it is a simple algorithm that can easily be implemented on a computer
- it's an efficient way to check if a list is already in order
- doesn't use a lot of memory as all the sorting is done using the original list
Bubble sort disadvantages
- it is an inefficient way to sort a list
- due to being inefficient, the bubble sort algorithm doesn't cope well with a very
large list
Merge Sort
A 2 stage sort, 1st stage - the list is successively divided in half, forming 2 sublists
and is repeated until each sublist is of length one. 2nd stage - each pair of lists are
merged in order until there is one sorted string of numbers remaining
Merge Sort Advantages
Much more efficient process as it takes much less time to execute
Merge sort disadvantages
It is quite a difficult algorithm to implement and it requires more memory to store all
the sublists which is an issue for large lists
Data types
Integer - A whole number - 2 or 4 bytes
Real / Float / Double - A decimal number - 4 or 8 bytes
Char - A single character - 1 byte
String - Many characters - 1 byte per character
Boolean - True / False - 1 byte
Arithmetic Operators
+ - addition
- - subtraction
* - multiplication
/ - real division ( = 2.5)
^ - power
DIV (\) - integer division (5 \ 2 = 2)
MOD - remainder division (5 MOD 2 = 1)
Relational Operators
Used to compare
< - less than
> - more than
≥ or >= - more than or equal to
≤ or <= - less than or equal to
≠ or != or <> - not equal to
= - equal to
String handling operations
, STRING_TO_INT - Converts a string to an integer
INT_TO_STRING - Converts an integer to a string
STRING_TO_REAL - Converts a string to a real
REAL_TO_STRING - Converts a real to a string
CODE_TO_CHAR - Converts Unicode to a character
CHAR_TO_CODE - Converts a character to Unicode
String Manipulation
LEN - Finds the length of a string, begins counting at 1
SUBSTRING - Outputs a section of a string from given parameters, begins counting
at 0
POSITION - Outputs the position of a character in a string, begins counting at 0
Concatenation - The joining together of multiple strings
Variables
Structures that can store 1 piece of information of one data type. can be rewritten
later
Arrays
Structures that can store multiple pieces of information of one data type. Can be
rewritten later
Selection Definition
A generic term for a type of programming statement (usually an if-statement) that
uses a Boolean condition to determine, or select, whether or not to run a certain
block of statements.
Iteration
a structure that involves the use of loops, e.g. For loops, Repeat until loops, While
loops
Robust code
The program will function reliably and not crash or go into infinite loops, even with
incorrect inputs or unpredictable values.
Subroutine
a set of instructions designed to perform a frequently used operation within a
program. Used when the same series of commands are repeated multiple times. A
subordinate routine; specifically, a sequence of computer instructions for performing
a specified task that can be used repeatedly.
Subroutine types
Procedures and Functions
Procedures
Procedures are a type of subroutine. They contain a set of instructions which are
executed when the procedure is called to run. A procedure will not return a value
back to the main program.
Global Variable
A variable that can be used in any part of the program.
local variable
A local variable is one which is defined in a sub routine.
What is parameter passing
Parameter passing refers to the process of passing a value (an argument) into a
subroutine.
Arguement
An argument is the actual value being passed into a subroutine.
Parameter
A parameter is the subroutine's variable which will receive the argument.
PROGRAMMING
Algorithm
A methodical, logical rule or procedure that guarantees solving a particular problem.
Difference between algorithms and computer programs
Computer programs are implementations of algorithms
Decomposition
The process of breaking down larger problems into smaller more manageable sub
problems
Abstraction
The removal of unnecessary information to make a problem easier to understand
Steps to answer : Describe this algorithm in terms of inputs and outputs
1) draw an input and output table that shows the inputs and outputs
2) State the inputs, what data structure they are, their datatype and its name
3) State the outputs, what data structure they are, their datatype, where its going and
its name
Steps to answer : why one algorithm is more efficient than another
1) Compare how many calculations are taking place
2) Compare the number of complex structures (Iteration and Selection)
3) And therefore it would run in less time
DO NOT SAY THERE ARE FEWER LINES OF CODES CAUSE THAT IS WRONG
AND JUST STUPID
Flowcharts
A graphical representation of the steps in a process; details all of the elements in a
process and the sequence in which these elements occur. A form of algorithm
Oval
Shows the start and end of a flowchart
Rectangle
A process, i.e addition, division
Parallelogram
An input or output
Diamond
A decision
Arrows
Shows the flow of information
Linear Search
a method for finding a target value within a list. It sequentially checks each element
of the list for the target value until a match is found or until all the elements have
been searched. Works even if the list is unsorted.
linear search advantages
Simple, Works on unsorted data
Linear search disadvantages
Not efficient in very long lists
Binary Search
Looking for an item in an already sorted list by eliminating large portions of the data
on each comparison. Continuously divides the list in 2 discarding the set which has
numbers greater than the number being searched.
,Binary search advantages
Extremely efficient
Binary search disadvantages
Doesn't work on unsorted data
Bubble Sort
A sort in which the first two items to be sorted are examined and exchanged if
necessary to place them in the specified order; the second item is then compared
with the third (exchanging them if required), the third is compared with the fourth,
and the process is repeated until all pairs have been examined and all items are in
the proper sequence.
Bubble sort advantages
- it is a simple algorithm that can easily be implemented on a computer
- it's an efficient way to check if a list is already in order
- doesn't use a lot of memory as all the sorting is done using the original list
Bubble sort disadvantages
- it is an inefficient way to sort a list
- due to being inefficient, the bubble sort algorithm doesn't cope well with a very
large list
Merge Sort
A 2 stage sort, 1st stage - the list is successively divided in half, forming 2 sublists
and is repeated until each sublist is of length one. 2nd stage - each pair of lists are
merged in order until there is one sorted string of numbers remaining
Merge Sort Advantages
Much more efficient process as it takes much less time to execute
Merge sort disadvantages
It is quite a difficult algorithm to implement and it requires more memory to store all
the sublists which is an issue for large lists
Data types
Integer - A whole number - 2 or 4 bytes
Real / Float / Double - A decimal number - 4 or 8 bytes
Char - A single character - 1 byte
String - Many characters - 1 byte per character
Boolean - True / False - 1 byte
Arithmetic Operators
+ - addition
- - subtraction
* - multiplication
/ - real division ( = 2.5)
^ - power
DIV (\) - integer division (5 \ 2 = 2)
MOD - remainder division (5 MOD 2 = 1)
Relational Operators
Used to compare
< - less than
> - more than
≥ or >= - more than or equal to
≤ or <= - less than or equal to
≠ or != or <> - not equal to
= - equal to
String handling operations
, STRING_TO_INT - Converts a string to an integer
INT_TO_STRING - Converts an integer to a string
STRING_TO_REAL - Converts a string to a real
REAL_TO_STRING - Converts a real to a string
CODE_TO_CHAR - Converts Unicode to a character
CHAR_TO_CODE - Converts a character to Unicode
String Manipulation
LEN - Finds the length of a string, begins counting at 1
SUBSTRING - Outputs a section of a string from given parameters, begins counting
at 0
POSITION - Outputs the position of a character in a string, begins counting at 0
Concatenation - The joining together of multiple strings
Variables
Structures that can store 1 piece of information of one data type. can be rewritten
later
Arrays
Structures that can store multiple pieces of information of one data type. Can be
rewritten later
Selection Definition
A generic term for a type of programming statement (usually an if-statement) that
uses a Boolean condition to determine, or select, whether or not to run a certain
block of statements.
Iteration
a structure that involves the use of loops, e.g. For loops, Repeat until loops, While
loops
Robust code
The program will function reliably and not crash or go into infinite loops, even with
incorrect inputs or unpredictable values.
Subroutine
a set of instructions designed to perform a frequently used operation within a
program. Used when the same series of commands are repeated multiple times. A
subordinate routine; specifically, a sequence of computer instructions for performing
a specified task that can be used repeatedly.
Subroutine types
Procedures and Functions
Procedures
Procedures are a type of subroutine. They contain a set of instructions which are
executed when the procedure is called to run. A procedure will not return a value
back to the main program.
Global Variable
A variable that can be used in any part of the program.
local variable
A local variable is one which is defined in a sub routine.
What is parameter passing
Parameter passing refers to the process of passing a value (an argument) into a
subroutine.
Arguement
An argument is the actual value being passed into a subroutine.
Parameter
A parameter is the subroutine's variable which will receive the argument.