All papers

Computer Science · AQA 7517 · Paper 1: On-screen exam · June 2022

AQA A Level Computer Science Paper 1: On-screen exam June 2022 question paper 7517/1

2h 30m

AQA 7517 · Paper 1

14 questions
Report a problem
What is wrong?

Goes to whoever maintains the question split. No account needed and nothing is published on this page.

Question 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.

Figure for question 1

Copy the contents of the unshaded cells in Table 1 into the table in your Electronic Answer Document.

[3 marks]

Answer
Mark scheme for question 1

Question 2

A queue data structure can be implemented as a static data structure using an array.

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]

Answer
Mark scheme for question 2.1

Describe three differences between dynamic and static data structures.

[3 marks]

Answer
Mark scheme for question 2.2

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

Figure for question 2

What value will be returned by applying the peek operation to S ?

[1 mark]

Answer
Mark scheme for question 2.3

What value will be returned by applying the pop operation to S ?

[1 mark]

Answer
Mark scheme for question 2.4

Explain how a single stack can be used to reverse the order of the items in a queue.

[2 marks]

Answer
Mark scheme for question 2.5

Question 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.

Explain why Statement 1 is not correct.

[1 mark]

Answer
Mark scheme for question 3.1

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

[1 mark]

Answer
Mark scheme for question 3.2

For two statements other than Statement 1 and your answer to Question 03.2, explain why those statements are not correct.

[2 marks]

Answer
Mark scheme for question 3.3

Question 4

For each of the statements in Table 2, complete each row to indicate if the statement is true or false for Dijkstra’s algorithm.

Figure for question 4

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

[2 marks]

Answer
Mark scheme for question 4.1
Figure for question 4

[1 mark]

Answer
Mark scheme for question 4.2
Figure for question 4 Figure for question 4

[2 marks]

Answer
Mark scheme for question 4.3

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 for question 4

Complete the unshaded cells in Table 4 to show how the graph in Figure 7 would be represented as an adjacency matrix.

Figure for question 4

Copy the contents of the unshaded cells in Table 4 into the table in your Electronic Answer Document.

[1 mark]

Answer
Mark scheme for question 4.4
Figure for question 4 Figure for question 4

[6 marks]

Answer
Mark scheme for question 4.5

What is the purpose of the subroutine G ?

[1 mark]

Answer
Mark scheme for question 4.6

State the type of graph traversal used in subroutine G.

[1 mark]

Answer
Mark scheme for question 4.7
Figure for question 4

[1 mark]

Answer
Mark scheme for question 4.8

Question 5

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.

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 n th 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.

Figure for question 5
Figure for question 5

[12 marks]

Answer
Mark scheme for question 5.1
Figure for question 5

[1 mark]

Answer
Mark scheme for question 5.2

Question 6

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.

An incomplete class diagram of the user-defined classes for part of the Skeleton Program is shown in Figure 8.

Figure for question 6
Figure for question 6

[1 mark]

Answer
Mark scheme for question 6.1
Figure for question 6

[1 mark]

Answer
Mark scheme for question 6.2

Explain the difference between an attribute that has a public specifier and an attribute that has a protected specifier.

[2 marks]

Answer
Mark scheme for question 6.3

In object-oriented programming, what is meant by overriding?

[1 mark]

Answer
Mark scheme for question 6.4

Question 7

This question is about the CardCollection class.

Figure for question 7

[1 mark]

Answer
Mark scheme for question 7.1

The CardCollection class uses a list to store the cards.

State one reason why a set could not have been used instead of a list.

[1 mark]

Answer
Mark scheme for question 7.2

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

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

[3 marks]

Answer
Mark scheme for question 7.3

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

Explain why a hash table is a suitable choice.

[1 mark]

Answer
Mark scheme for question 7.4

Question 8

An incomplete hierarchy diagram of the user-defined subroutines in part of the Skeleton Program is shown in Figure 11.

Figure for question 8
Figure for question 8

[1 mark]

Answer
Mark scheme for question 8.1

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]

Answer
Mark scheme for question 8.2

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]

Answer
Mark scheme for question 8.3

Explain why the call to the subroutine AddDifficultyCardsToDeck is after, not before, the iteration structure in the SetupGame subroutine.

[1 mark]

Answer
Mark scheme for question 8.4

Question 9

How many subroutines in the Skeleton Program access external data files?

[1 mark]

Answer
Mark scheme for question 9

Question 10

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]

Answer
Mark scheme for question 10

Question 11

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.

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:

maths symbol run the Skeleton Program

maths symbol play a new game

maths symbol enter U

maths symbol enter 2

maths symbol enter L

maths symbol enter D

Figure for question 11
Figure for question 11

[4 marks]

Answer
Mark scheme for question 11.1
Figure for question 11

[1 mark]

Answer
Mark scheme for question 11.2

Question 12

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:

maths symbol run the Skeleton Program

maths symbol play a new game

maths symbol enter U

maths symbol enter 2

maths symbol enter D

Figure for question 12
Figure for question 12

[8 marks]

Answer
Mark scheme for question 12.1
Figure for question 12

[1 mark]

Answer
Mark scheme for question 12.2

Question 13

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:

maths symbol change the status of the blasting cap to show that it has been used

maths symbol 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)

maths symbol 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.

maths symbol 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.

maths symbol 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:

maths symbol run the Skeleton Program

maths symbol enter L

maths symbol choose to use a blasting cap

maths symbol choose to complete the third challenge on the current lock

maths symbol choose to use a blasting cap.

Figure for question 13
Figure for question 13

[9 marks]

Answer
Mark scheme for question 13.1
Figure for question 13

[1 mark]

Answer
Mark scheme for question 13.2

Question 14

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:

maths symbol 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

maths symbol 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 TrapCard s instead of DifficultyCard s.

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.

Task 4 Test that the changes you have made work:

maths symbol run the Skeleton Program

maths symbol enter L

maths symbol enter U

maths symbol enter 1

maths symbol enter P

maths symbol enter U

maths symbol enter 1

maths symbol enter P

maths symbol enter D

Figure for question 14
Figure for question 14

[12 marks]

Answer
Mark scheme for question 14.1
Figure for question 14

[1 mark]

Answer
Mark scheme for question 14.2

The paper as printed

Spotted a mistake on this page?Report a problem