Question Paper
Question Paper
COMPUTER SCIENCE
Paper 1
Instructions
• Type the information required on the front of your Electronic Answer Document.
• Before the start of the examination make sure your Centre Number, Candidate Name and
Candidate Number are shown clearly in the footer of every page (also at the top of the front
cover) of your Electronic Answer Document.
• Enter your answers into the Electronic Answer Document.
• Answer all questions.
• Save your work at regular intervals.
Information
• The marks for questions are shown in brackets.
• The maximum mark for this paper is 100.
• No extra time is allowed for printing and collating.
• The question paper is divided into four sections.
Advice
You are advised to allocate time to each section as follows:
Section A – 40 minutes; Section B – 20 minutes; Section C – 20 minutes; Section D – 70 minutes.
Warning
It may not be possible to issue a result for this paper if your details are not on every page of your
Electronic Answer Document.
IB/G/Jun22/E12 7517/1
2
Section A
State the Big-O time complexity of each of these algorithms. The first row has been
completed for you.
Table 1
Bubble sort
Linear search
Merge sort
Copy the contents of the unshaded cells in Table 1 into the table in your Electronic
Answer Document.
[3 marks]
IB/G/Jun22/7517/1
3
0 2 A queue data structure can be implemented as a static data structure using an array.
0 2 . 1 Describe the method that would need to be followed to attempt to remove an item
from a circular queue implemented as a static data structure using an array.
Your method should deal appropriately with any issues which could arise.
[4 marks]
Figure 1 shows data that has been stored in a stack implemented using an array S.
Figure 1
[7]
[6]
[5]
[4]
[3]
[1] Skye
[0] Harry
0 2 . 5 Explain how a single stack can be used to reverse the order of the items in a queue.
[2 marks]
Turn over ►
IB/G/Jun22/7517/1
4
Figure 2
0 3 . 3 For two statements other than Statement 1 and your answer to Question 03.2, explain
why those statements are not correct.
[2 marks]
IB/G/Jun22/7517/1
5
0 4 . 1 For each of the statements in Table 2, complete each row to indicate if the statement
is true or false for Dijkstra’s algorithm.
Table 2
True or
False?
Calculates the shortest path between a node and other
nodes in a graph.
Can be used to prove that the Halting Problem cannot be
solved.
Copy the contents of the unshaded cells in Table 2 into the table in your Electronic
Answer Document.
[2 marks]
Figure 3
FUNCTION G(V, P)
Visited[V] True
FOR EACH N IN ConnectedNodes[V]
IF Visited[N] = False THEN
IF G(N, V) = True THEN
RETURN True
ENDIF
ELSE IF N ≠ P THEN
RETURN True
ENDIF
ENDFOR
RETURN False
ENDFUNCTION
Turn over ►
IB/G/Jun22/7517/1
6
Figure 3 (repeated)
FUNCTION G(V, P)
Visited[V] True
FOR EACH N IN ConnectedNodes[V]
IF Visited[N] = False THEN
IF G(N, V) = True THEN
RETURN True
ENDIF
ELSE IF N ≠ P THEN
RETURN True
ENDIF
ENDFOR
RETURN False
ENDFUNCTION
Figure 4
FUNCTION F()
FOR Count 0 TO LENGTH(Visited) - 1
IF Visited[Count] = False THEN
RETURN False
ENDIF
ENDFOR
RETURN True
ENDFUNCTION
Figure 5
FUNCTION E()
Set all elements of Visited to False
IF G(0, -1) = True THEN
RETURN False
ELSE
RETURN F()
ENDIF
ENDFUNCTION
IB/G/Jun22/7517/1
7
Figure 6 shows a graph consisting of three nodes, the contents of the array
ConnectedNodes when it is used to represent this graph, and the contents of the
array Visited after the subroutine call G(0, -1).
Figure 6
0 4 . 3 Complete the unshaded cells in Table 3 to show the result of the subroutine call F()
when it is applied using the graph shown in Figure 6.
Table 3
Value
Count returned
Copy the contents of the unshaded cells in Table 3 into the table in your Electronic
Answer Document.
[2 marks]
Turn over ►
IB/G/Jun22/7517/1
8
Figure 7 shows a graph consisting of four nodes and the contents of the array
ConnectedNodes when it is used to represent this graph.
Figure 7
0 4 . 4 Complete the unshaded cells in Table 4 to show how the graph in Figure 7 would be
represented as an adjacency matrix.
Table 4
0 1 2 3
Copy the contents of the unshaded cells in Table 4 into the table in your Electronic
Answer Document.
[1 mark]
Figure 3 (repeated)
FUNCTION G(V, P)
Visited[V] True
FOR EACH N IN ConnectedNodes[V]
IF Visited[N] = False THEN
IF G(N, V) = True THEN
RETURN True
ENDIF
ELSE IF N ≠ P THEN
RETURN True
ENDIF
ENDFOR
RETURN False
ENDFUNCTION
IB/G/Jun22/7517/1
9
0 4 . 5 Complete the unshaded cells in Table 5 to show the result of the subroutine call
G(0, -1) on the graph shown in Figure 7. Some parts of the table, including the
initial values in the Visited array, have been completed for you.
Table 5
Visited
Subroutine
V P [0] [1] [2] [3] N
call
False False False False
G(0, -1)
Final value
returned:
Copy the contents of the unshaded cells in Table 5 into the table in your Electronic
Answer Document.
[6 marks]
Turn over ►
IB/G/Jun22/7517/1
10
Section B
0 5 Write a program that asks the user to enter a string. It should then change the order
of the vowels in the string and display the result.
If there are n vowels in the string, the 1st vowel in the string should swap with the nth
vowel in the string, the 2nd vowel in the string should swap with the (n-1)th vowel in
the string, and so on.
Examples
If the user enters the string horse then the program should display the
string herso.
If the user enters the string goose then the program should display the
string geoso.
If the user enters the string nakedmolerat then the program should
display the string nakedmolerat.
If the user enters the string lynx then the program should display the
string lynx.
If the user enters the string pig then the program should display the
string pig.
You may assume the string that the user enters will only contain lowercase letters.
IB/G/Jun22/7517/1
11
0 5 . 2 SCREEN CAPTURE(S) showing the results of three tests of the program by entering
the strings persepolis, darius and xerxes.
[1 mark]
Turn over ►
IB/G/Jun22/7517/1
12
Section C
These questions refer to the Preliminary Material and the Skeleton Program, but do not require
any additional programming.
Refer either to the Preliminary Material issued with this question paper or your electronic copy.
0 6 An incomplete class diagram of the user-defined classes for part of the Skeleton
Program is shown in Figure 8.
Figure 8
IB/G/Jun22/7517/1
13
0 6 . 1 State the type of relationship the diagram in Figure 8 shows between the class
indicated by and the class indicated by .
[1 mark]
0 6 . 3 Explain the difference between an attribute that has a public specifier and an attribute
that has a protected specifier.
[2 marks]
Turn over ►
IB/G/Jun22/7517/1
14
Figure 9
TempCard Cards[RNo1]
Cards[RNo1] Cards[RNo2]
Cards[RNo2] TempCard
Figure 10
Cards[RNo1] Cards[RNo2]
Cards[RNo2] Cards[RNo1]
Explain why the Shuffle subroutine would not work if it used the method shown in
Figure 10 instead of the method shown in Figure 9.
[1 mark]
0 7 . 2 State one reason why a set could not have been used instead of a list.
[1 mark]
IB/G/Jun22/7517/1
15
Figure 11
0 8 . 3 State one actual data value that will always be in the stack frame added to the stack
when the subroutine LoadGame is called from the SetupGame subroutine.
[1 mark]
Turn over ►
IB/G/Jun22/7517/1
16
0 9 How many subroutines in the Skeleton Program access external data files?
[1 mark]
You should not make any changes to the Skeleton Program to answer this question.
[1 mark]
IB/G/Jun22/7517/1
17
Section D
The program is to be changed so that it checks that the choice entered after the
player has chosen to use a card is valid. D and P are the only valid choices. The
program should keep getting the player to enter a value until a valid choice has been
made.
Task 1
Modify the subroutine GetDiscardOrPlayChoice so it checks that the value
entered by the player is valid. An appropriate error message should be displayed if an
invalid value is entered and the user should be made to enter another value.
Task 2
Test that the changes you have made work:
Turn over ►
IB/G/Jun22/7517/1
18
1 2 This question extends the Skeleton Program so that it displays some information
about the contents of the deck to the player.
The program needs to be modified so that it displays messages telling the player how
many cards are in the deck and how many tool cards there are in the deck. A tool
card is a pick, file, or key.
Task 1
Modify the PlayGame subroutine in the Breakthrough class so that a message is
displayed telling the player how many cards there are in the deck.
This message should be displayed after the message telling the player what their
current score is and before the contents of the player’s hand are displayed.
Task 2
Create a subroutine GetNumberOfToolCards in the CardCollection class
that calculates how many tool cards there are in the Cards data structure. It should
return the calculated value to the calling routine.
Task 3
Modify the PlayGame subroutine in the Breakthrough class so that a message is
displayed telling the player how many tool cards there are in Deck. This message
should use the value returned by calling the GetNumberOfToolCards subroutine
for Deck.
This message should be displayed after the message telling the player what their
current score is and before the contents of the player’s hand are displayed.
Task 4
Test that the changes you have made work:
IB/G/Jun22/7517/1
19
1 3 This question extends the Skeleton Program by allowing a player to use a blasting
cap to complete any challenge on the current lock.
When the player chooses to use the blasting cap, the program should check if the
player has already used the blasting cap. If they have not used the blasting cap, the
program should:
• change the status of the blasting cap to show that it has been used
• ask the player to enter the position of the challenge on the current lock they would
like to use the blasting cap on (1 for the first challenge, 2 for the second challenge,
etc)
• check:
o that the position entered is less than or equal to the number of challenges on the
current lock
o that the challenge in that position has not already been met.
• if both these checks are passed:
o mark the challenge as being met
o display a message saying the blasting cap was used successfully
o display the details for the current lock.
• if either of these checks fail, then the blasting cap has been wasted and the game
continues.
If the player tries to use the blasting cap when they have already used it then nothing
changes and the game continues.
Task 1
Modify the GetChoice subroutine in the Breakthrough class so the message
displayed shows the blasting cap option.
Task 2
Modify the PlayGame subroutine in the Breakthrough class so that there is a
blasting cap that works in the way described.
Task 3
Test that the changes you have made work:
1 3 . 1 Your PROGRAM SOURCE CODE for the amended subroutines GetChoice and
PlayGame.
[9 marks]
1 4 This question adds a new type of difficulty card to the game, a trap.
When the player draws a trap card from the deck, it works as follows:
• if no challenges from the current lock have been met, the trap card works in the
same way as a difficulty card and the player’s choice to lose a key or discard five
cards is executed
• if one or more challenges from the current lock have been met, one of the met
challenges is randomly chosen and has its status changed so it is no longer met.
This happens instead of executing the player’s choice to lose a key or discard five
cards from the deck.
Trap cards are used in the game instead of difficulty cards when the player chooses to
load a game from a file. They are not used when the player chooses to play a new
game.
Task 1
Create a new class called TrapCard that is a subclass of the DifficultyCard
class.
The constructor for this new class should set the value of CardNumber to the value
of the constructor’s parameter and set the value of CardType to Trp.
Create a subroutine Process in the TrapCard class that overrides the subroutine
from the DifficultyCard class and allows a trap card to work in the way
described.
Task 2
Modify the SetupCardCollectionFromGameFile subroutine in the
Breakthrough class so that it creates TrapCards instead of
DifficultyCards.
Task 3
Modify the GetCardFromDeck subroutine in the Breakthrough class so that if
the top card of the deck has a CardType of Trp, that card is treated in the same
way as if the top card of the deck had a CardType of Dif.
When the top card of the deck has a CardType of Trp, the message "Trap!"
should be displayed.
IB/G/Jun22/7517/1
21
Task 4
Test that the changes you have made work:
END OF QUESTIONS
IB/G/Jun22/7517/1
22
IB/G/Jun22/7517/1
23
IB/G/Jun22/7517/1
24
Copyright information
For confidentiality purposes, all acknowledgements of third-party copyright material are published in a separate booklet. This booklet is published after
each live examination series and is available for free download from www.aqa.org.uk.
Permission to reproduce all copyright material has been applied for. In some cases, efforts to contact copyright-holders may have been unsuccessful and
AQA will be happy to rectify any omissions of acknowledgements. If you have any queries please contact the Copyright Team.
*226A7517/1*
IB/G/Jun22/7517/1