Professional Documents
Culture Documents
Allows focus to be placed on the immediate data that is currently important. (1)
It does not represent the entirety of the reality itself as some data has been removed. (1)
4 It can hide the complexity of the program to allow focus on the immediate problem. (2)
It filters out unnecessary detail to create a representation of the current problem that needs
solving. (2)
5 Don’t need to refer to detail such as how many steps to take. (1)
Would filter out many buildings and landmarks, only referring to the major ones. (1)
Don’t need to refer to every road that is passed, only the ones where turns need to be made. (1)
Elements of computational thinking
Thinking ahead
6 It allows us to future-proof our program. (1)
7 If we do not identify the correct inputs, then we may not get the correct outputs. (1)
If we do not plan for future inputs that may be needed, we may not be able to create the correct or
desired outputs. (1)
8 Libraries are pre-programmed sections of code that can be imported into our program. (1)
The creators of the programming language have thought about what common functions need to be
used and have created a library to do this, saving time. (1)
9 Caching is storing data and instructions in a temporary data store for easier access. (1)
It is anticipated which data and instructions are likely to be used most and these are added to the
cache. (1)
Thinking procedurally
10 To think about the sequence of the component parts of a solution. (1)
To make sure that the component parts are in the correct order to achieve the right output or
result. (1)
There may be more than one way of achieving the output/result, so it can allow the most efficient
method to be identified. (1)
Thinking logically
13 One of: (1)
Use a flowchart.
Use pseudocode.
Thinking concurrently
14 Tasks can be completed in a faster time. (1)
Exam-style questions
16 a Decomposition: breaking down a problem into smaller parts. (1)
Problem recognition
Think of all the surrounding data that may be encountered in a flight scenario.
Assess which data is not useful for the user in the simulation.
Create a simulation that will include only the data that has been identified as important.
18 It allows the computer to complete more than one task at a time. (1)
It can fetch the next instruction whilst still processing the current instruction. (1)
It can divide larger problems into smaller parts and process them at the same time. (1)
It uses it to create the best performance ability possible for the computer. (1)
19 They allow us to use logic to decide what we would like for dinner. (1)
They do not consider any of our emotional feelings about what we might want for dinner. (1)
Analysis can take place to see which tasks can be completed alongside others.
Assembly lines can be set to manufacture multiple parts of the product at the same time.
All the parts can be assembled at the end to create the final product more efficiently.
Some parts of the assembly line can be spraypainting parts whilst others are manufacturing
them (or another valid example).
The website may be viewed hundreds of times a week and caching can speed up the process
of accessing web pages.
Once the content for a web page is requested once, it can be cached on a server, making it
quicker to access next time.
The increased performance of the website, gained through caching, may attract more viewers.
Caching can help the website deal with high volumes of traffic if they spike at certain points in
the day/week.
4 A loop (1)
Steps working toward the base case (also known as general case). (1)
7 A global variable is declared outside a subroutine and can be accessed at any time. (1)
A local variable is declared within a subroutine and can only be accessed within the subroutine. (1)
8 It means that it is less likely to be accidentally changed somewhere else in the program. (1)
It allows for greater data security, as changes need only be made in one place rather than in
multiple places in the program.
11 A function is a set of instructions designed to return a value, e.g. addition of values to gain a total.
(1)
A procedure is set of instructions designed to perform a task that would not return a value, e.g. sort
data. (1)
13 In passing by value, only a copy of the variable is passed into the subroutine. (1)
In passing by reference, the address of the variable is passed into the subroutine. (1)
14 Tools, such as pretty printing and auto-completion, can help the programmer understand that they
have the correct commands when writing the program. (1)
It can provide a testing environment and highlight where errors are present in the program. (1)
16 a, b (6)
This is only a possible solution; student solutions may differ as different attributes and methods
can be used.
Animal
Height : Real
Weight : Real
Colour : String
Furry : Boolean
Age : Integer
getHeight()
getWeight()
getColour()
getFurry()
getAge()
setHeight()
setWeight()
setColour()
setFurry()
setAge()
Age_in_human_years()
Dog Cat
Breed : String Breed : String
Tail : Boolean Tail : Boolean
getBreed() getBreed()
getTail() getTail()
setBreed() setBreed()
setTail() setTail()
Age_in_human_years() Age_in_human_years()
17 (2)
This is only a possible solution; student solutions may differ as different attributes and methods
can be used.
function getHeight()
return Height
endfunction
18 (2)
This is only a possible solution; student solutions may differ as different attributes and methods
can be used.
procedure setHeight(newHeight)
Height = newHeight
endprocedure
19 (3)
This is only a possible solution; student solutions may differ as different attributes and methods
can be used.
private Breed
private Tail
Breed = newBreed
Tail = newTail
endprocedure
endclass
20 (1)
This is only a possible solution; student solutions may differ as different attributes and methods
can be used.
21 (2)
This is only a possible solution; student solutions may differ as different attributes and methods
can be used.
Computational methods
22 An algorithm can be created to solve the problem. (1)
The underlying issues are too complex and are not understood.
26 It is easy to see which modules relate to each other, and are dependent on each other. (1)
27 It assumes the entire solution to the problem is known in advance, (1) which may not always be
possible, especially if event-driven programming is used. (1)
The program is broken down into different modules, which are the classes within the program. (1)
The Fibonacci sequence is found by a repetitive process (the addition of the previous two values to
make the current value). (1)
Recursion can be used to return each value, which is an example of divide and conquer. (1)
30 You may need to try one pattern of numbers to see if that works. (1)
But you may then hit a situation where it stops working, so you need to backtrack to the last point it
was working and try a different pattern. (1)
You could backtrack to the point it was working and think what has been done since.
If that doesn’t resolve the issue you can try another troubleshooting solution.
33 The company could analyse large sets of data about the current markets of their possible new
products. (1)
The data mining may reveal trends relating to the possible new products and help the company
decide which would be the most viable. (1)
34 It is a ‘rule of thumb’ thought that is developed through the experiences we have had in our lives.
(1)
36 A program can be designed to use a heuristic approach to intelligently guess how to solve a
problem. (1)
38 The company can save money as they can repeatedly run the same tests or different tests in a
simulated situation. (1)
The company can save time as they wouldn’t need to wait for a physical model to be built each
time, or for a scenario to be reset. (1)
It is limited to dealing with the problems and issues that we are able to think of. (1)
42 It allows multiple instructions to be executed at the same time (in parallel). (1)
43 It is not always possible to predict the next instruction needed if branching occurs in a program. (1)
A bar chart could quickly show which train routes are used the most.
A plan of all the train routes colour co-ordinated for level of use.
Exam-style questions
45 (4)
Parking meter
Calculate Calculate
Calculate cost
change expiry time
46 a To initialise all the values for the attributes in the class. (1)
d (5)
class monthlyWage
private Name
private Salary
private Overtime
Name = newName
Salary = newSalary
Overtime = newOvertime
endprocedure
endclass
47 In a divide and conquer approach, problems are broken down into their smallest possible
components. (1)
Two examples are recursion and binary search (other possible examples may be given). (2)
Algorithms
1 Any one of: (1)
Data structures
4 Polynomial complexity OR O(nk) (1)
7 (4)
function popFromStack()
indexFirst = 0
indexLast = 4
pointerTemp = endPointer
return false
else
valueToPop = stack[pointerTemp].data
endPointer = pointerTemp - 1
return true
endif
endfunction
9 It has reached the end of the queue, so it needs to go back to the beginning. (1)
10 There is no free space in the queue for the value to be added. (1)
11 (4)
function popFromQueue()
return false
else
valueToPop = queue[StartPointer].data
if StartPointer = 4 then
StartPointer = 0
else
StartPointer = StartPointer + 1
return true
endif
endif
endfunction
currentPointer = startingPointer // sets the current pointer in the list to the start pointer
while currentPointer != nullPointer and list[currentPointer].data != dataItem // sets to loop while the
current pointer is not null and the current data item is not the one to be found
endwhile
return currentPointer // returns the place in the list where the value is found
endfunction
13 The pointer from the previous node is disconnected from the value to be removed. (1)
The pointer from the value to be removed to the next node is disconnected and the deleted item is
added to the list of free space. (1)
The pointer is set to bypass the value to be removed and now points to the next value in the list
instead. (1)
14 The route node is the main node at the top of the hierarchy. (1)
16 (4)
Monkey
Elephant Tiger
Gorilla
18 To visit all nodes attached to a node connected to a starting node, before visiting a second node
attached to a starting node. (1)
pointer = 0
indexMax = 9
pointer = pointer + 1
endwhile
else
22 (7)
lowerBound = 0
upperBound = lengthOfList – 1
found = false
found = true
lowerBound = midpoint + 1
else
upperBound = midpoint – 1
OCR AS/A level Workbook: Computer Science 2
endif
endwhile
print("Not in list")
else
endif
24 If it doesn’t need to swap any values in a pass, it knows the data is in order. (1)
25 (3)
C F A B E D G
C A B E D F G
1st pass
A B C D E F G
2nd pass
A B C D E F G
Final pass
26 (4)
5 24 66 32 16 47 51 19
24 55 66 32 16 47 51 19
24 55 66 32 16 47 51 19
24 32 55 66 16 47 51 19
16 24 32 55 66 47 51 19
16 24 32 47 55 66 51 19
16 24 32 47 51 55 66 19
16 19 24 32 47 51 55 66
27 (5)
numberOfValues = 8
for x = 2 to numberOfValues
valueToInsert = list[x]
index = x – 1
list[index + 1] = list[index]
endwhile
list[index] = valueToInsert
ENDFOR
28 (4)
55 24 66 32 16 47 51 19
24 55 32 66 16 47 19 51
24 32 55 66 16 19 47 51
16 19 24 32 47 51 55 66
29 a The merge sort (1) as it takes fewer passes/less processing of the data. (1)
b The insertion sort may be quicker if the data set was more sorted to begin with. (1)
30 (4)
Taking first item, making it the pivot and having the correct values each sublist. (1)
Making the first item in each sublist the pivot and having the correct values in the sublists. (1)
55 24 66 32 16 47 51 19
24 32 16 47 51 19 55 66
16 19 24 32 47 51 55 66
16 19 24 32 47 51 55 66
16 19 24 32 47 51 55 66
16 19 24 32 47 51 55 66
32 A–B–I–J (1)
Exam-style questions
34 (4)
c Parameter (1)
36 The size of the array will be set (most likely to the size of the queue). (1)
The first piece of data added to the queue will be stored in the first element of the array. (1)
Further pieces of data added to the queue will be stored in the following elements of the array, in
the order added. (1)