0% found this document useful (0 votes)
118 views24 pages

Question Paper

The document provides instructions for a computer science exam paper. It includes 4 sections and advises allocating 40 minutes to section A, 20 minutes each to sections B and C, and 70 minutes to section D. Section A includes questions on Big-O notation, queues, stacks, and logic puzzles. Section B and C continue with additional questions.

Uploaded by

augustasjonikas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
118 views24 pages

Question Paper

The document provides instructions for a computer science exam paper. It includes 4 sections and advises allocating 40 minutes to section A, 20 minutes each to sections B and C, and 70 minutes to section D. Section A includes questions on Big-O notation, queues, stacks, and logic puzzles. Section B and C continue with additional questions.

Uploaded by

augustasjonikas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

A-level

COMPUTER SCIENCE
Paper 1

Time allowed: 2 hours 30 minutes


Materials
For this paper you must have:
• a computer
• a printer
• appropriate software
• the Electronic Answer Document
• an electronic version and a hard copy of the Skeleton Program
• an electronic version and a hard copy of the Preliminary Material
• an electronic version of the Data Files game1.txt and locks.txt
You must not use a calculator.

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.

At the end of the examination


Tie together all your printed Electronic Answer Document pages and hand them to the Invigilator.

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

You are advised to spend no longer than 40 minutes on this section.

Type your answers to Section A in your Electronic Answer Document.

You must save this document at regular intervals.

0 1 Big-O notation is used to express the time complexity of an algorithm. Table 1


contains a list of algorithms.

State the Big-O time complexity of each of these algorithms. The first row has been
completed for you.

Table 1

Algorithm Time complexity

Binary tree search O(log n)

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]

0 2 . 2 Describe three differences between dynamic and static data structures.


[3 marks]

Figure 1 shows data that has been stored in a stack implemented using an array S.

Figure 1

[7]

[6]

[5]

[4]

[3]

[2] Jib Top = 2

[1] Skye

[0] Harry

0 2 . 3 What value will be returned by applying the peek operation to S?


[1 mark]

0 2 . 4 What value will be returned by applying the pop operation to S?


[1 mark]

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 for the next question

Turn over ►
IB/G/Jun22/7517/1
4

0 3 Figure 2 shows a logic puzzle.

Figure 2

Which one of these six statements is correct?

Statement 1: All of the statements below are correct.

Statement 2: None of the statements below are correct.

Statement 3: All of the statements above are correct.

Statement 4: Exactly one of the statements above is correct.

Statement 5: None of the statements above are correct.

Statement 6: None of the statements above are correct.

0 3 . 1 Explain why Statement 1 is not correct.


[1 mark]

0 3 . 2 Which one of the six statements in Figure 2 is correct?


[1 mark]

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.

Can be used with both directed and undirected graphs.

Can be used with both weighted and unweighted graphs.

Copy the contents of the unshaded cells in Table 2 into the table in your Electronic
Answer Document.
[2 marks]

Figure 3 shows a subroutine represented using pseudo-code. The subroutine makes


use of an array Visited and an array ConnectedNodes that stores a graph
represented as an adjacency list.

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

0 4 . 2 The subroutine G uses recursion.

Explain what is meant by a recursive subroutine.


[1 mark]

Question 4 continues on the next page

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 shows a subroutine represented using pseudo-code. The subroutine makes


use of the array Visited.

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 shows a subroutine represented using pseudo-code. The subroutine makes


use of the subroutine G shown in Figure 3, the subroutine F shown in Figure 4 and
the array Visited.

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]

Question 4 continues on the next page

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]

0 4 . 6 What is the purpose of the subroutine G?


[1 mark]

0 4 . 7 State the type of graph traversal used in subroutine G.


[1 mark]

0 4 . 8 If the graph represented by ConnectedNodes is undirected, what can you


determine about the graph when a value of True is returned by subroutine E?
[1 mark]

Turn over for the next section

Turn over ►
IB/G/Jun22/7517/1
10

Section B

You are advised to spend no more than 20 minutes on this section.

Enter your answers to Section B in your Electronic Answer Document.

You must save this document at regular intervals.

The question in this section asks you to write program code


starting from a new program/project/file.

You are advised to save your program at regular intervals.

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.

The letters a, e, i, o and u are the only vowels.

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 pinkfairyarmadillo then the


program should display the string ponkfiaryarmidalli.

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

Evidence that you need to provide


Include the following evidence in your Electronic Answer Document.

0 5 . 1 Your PROGRAM SOURCE CODE.


[12 marks]

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 for the next section

Turn over ►
IB/G/Jun22/7517/1
12

Section C

You are advised to spend no more than 20 minutes on this section.

Type your answers to Section C into your Electronic Answer Document.

You must save this document at regular intervals.

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 . 2 State the identifier of the class indicated by in Figure 8.


[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]

0 6 . 4 In object-oriented programming, what is meant by overriding?


[1 mark]

Turn over for the next question

Turn over ►
IB/G/Jun22/7517/1
14

0 7 This question is about the CardCollection class.

0 7 . 1 Figure 9 shows a pseudo-code version of part of the Shuffle subroutine.


Figure 10 shows an alternative, incorrect version of the same part of the Shuffle
subroutine.

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]

The CardCollection class uses a list to store the cards.

0 7 . 2 State one reason why a set could not have been used instead of a list.
[1 mark]

0 7 . 3 A hash table could have been used instead of a list.

Describe how a card would be added to a hash table.


[3 marks]

0 7 . 4 A hash table can be used to implement a dictionary data structure.

Explain why a hash table is a suitable choice.


[1 mark]

IB/G/Jun22/7517/1
15

0 8 An incomplete hierarchy diagram of the user-defined subroutines in part of the


Skeleton Program is shown in Figure 11.

Figure 11

0 8 . 1 Which identifier should replace ?


[1 mark]

0 8 . 2 The value 5 is used in the subroutine SetupGame. It would be better to use a


named constant with an identifier that describes the purpose of the constant.

Suggest a suitable identifier for the named constant.


[1 mark]

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]

0 8 . 4 Explain why the call to the subroutine AddDifficultyCardsToDeck is after, not


before, the iteration structure in the SetupGame subroutine.
[1 mark]

Turn over for the next question

Turn over ►
IB/G/Jun22/7517/1
16

0 9 How many subroutines in the Skeleton Program access external data files?
[1 mark]

1 0 The user must input a D or P to select Discard or Play during a game.

Write a regular expression that would match the character D or P.

You should not make any changes to the Skeleton Program to answer this question.
[1 mark]

IB/G/Jun22/7517/1
17

Section D

You are advised to spend no more than 70 minutes on this section.

Enter your answers to Section D in your Electronic Answer Document.

You must save this document at regular intervals.

These questions require you to load the Skeleton Program and to


make programming changes to it.

1 1 This question refers to the subroutine GetDiscardOrPlayChoice in the


Breakthrough class.

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.

What you need to do

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:

• run the Skeleton Program


• play a new game
• enter U
• enter 2
• enter L
• enter D

Evidence that you need to provide


Include the following evidence in your Electronic Answer Document.

1 1 . 1 Your PROGRAM SOURCE CODE for the amended subroutine


GetDiscardOrPlayChoice.
[4 marks]

1 1 . 2 SCREEN CAPTURE(S) showing the results of the requested test.


[1 mark]

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.

What you need to do

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:

• run the Skeleton Program


• play a new game
• enter U
• enter 2
• enter D

Evidence that you need to provide


Include the following evidence in your Electronic Answer Document.

1 2 . 1 Your PROGRAM SOURCE CODE for the new subroutine


GetNumberOfToolCards and the amended PlayGame subroutine.
[8 marks]

1 2 . 2 SCREEN CAPTURE(S) showing the requested test.


[1 mark]

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.

The player will only be able to do this once per game.

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.

What you need to do

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:

• run the Skeleton Program


• enter L
• choose to use a blasting cap
• choose to complete the third challenge on the current lock
• choose to use a blasting cap.

Evidence that you need to provide


Include the following evidence in your Electronic Answer Document.

1 3 . 1 Your PROGRAM SOURCE CODE for the amended subroutines GetChoice and
PlayGame.
[9 marks]

1 3 . 2 SCREEN CAPTURE(S) showing the requested test.


[1 mark]
Turn over ►
IB/G/Jun22/7517/1
20

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.

What you need to do

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:

• run the Skeleton Program


• enter L
• enter U
• enter 1
• enter P
• enter U
• enter 1
• enter P
• enter D

Evidence that you need to provide


Include the following evidence in your Electronic Answer Document.

1 4 . 1 Your PROGRAM SOURCE CODE for the amended subroutine


GetCardFromDeck, the amended subroutine
SetupCardCollectionFromGameFile and the new class TrapCard.
[12 marks]

1 4 . 2 SCREEN CAPTURE(S) showing the requested test.


[1 mark]

END OF QUESTIONS

IB/G/Jun22/7517/1
22

There are no questions printed on this page

IB/G/Jun22/7517/1
23

There are no questions printed on this page

IB/G/Jun22/7517/1
24

There are no questions printed on this page

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.

Copyright © 2022 AQA and its licensors. All rights reserved.

*226A7517/1*
IB/G/Jun22/7517/1

You might also like