BREAKING
Student's code works, nobody knows why, including student★Local teen writes pseudocode, accidentally invents a language★Binary joke told in class, exactly 10 students laugh★
  1. Home
  2. A Level
  3. Computer Science
  4. OCR
  5. Thinking abstractly

OCR A Level Computer Science

Topic questions Algorithms Thinking abstractly

Thinking abstractly

8 questions · 221 marks · about 4 hours

Thinking abstractly questions

OCR H446 Thinking abstractly 8 questions

Algorithms and programming June 2024, Question 8 13 marks

A group of students are designing a racing car game. The game will allow players to enter their name and then a choice of vehicle. They will then race against other vehicles that will be controlled by the program. Players will use the arrow keys to control their vehicle.

(a)

The students are identifying the inputs and outputs for the game.

Complete the table by identifying two inputs and two outputs for the game.

Input 1........................................................................................................................ ........................................................................................................................
Input 2........................................................................................................................ ........................................................................................................................
Output 1........................................................................................................................ ........................................................................................................................
Output 2........................................................................................................................ ........................................................................................................................
[4]
Reveal mark scheme Mark scheme for question 8(a)
(b)

The students use abstraction during the design process.

(b)(i)

State what is meant by abstraction and describe how it can be used to design the racing car game.

[3]
Reveal mark scheme Mark scheme for question 8(b)(i)
(b)(ii)

Explain why it is beneficial to use abstraction when designing a computer program such as a game.

[3]
Reveal mark scheme Mark scheme for question 8(b)(ii)
(c)
(c)(i)

The group of students also use decomposition.

State what is meant by decomposition.

[1]
Reveal mark scheme Mark scheme for question 8(c)(i)
(c)(ii)

Describe one benefit of using decomposition when designing a computer program such as a game.

[2]
Reveal mark scheme Mark scheme for question 8(c)(ii)

Algorithms and programming June 2023, Question 9 40 marks

Also involves Arrays

A text-based computer game allows a user to dig for treasure on an island. The island is designed as a grid with 10 rows and 20 columns to store the treasure. Each square is given an x and y coordinate. Some of the squares in the grid store the name of a treasure object. Each treasure object has a value, e.g. 100 and a level, e.g. "Bronze."

(a)

The computer game makes use of abstraction.

(a)(i)

Describe what is meant by the term abstraction and give an example of how abstraction can be used in the treasure game.

[3]
Reveal mark scheme Mark scheme for question 9(a)(i)
(a)(ii)

Give three benefits of using abstraction when writing a program.

[3]
Reveal mark scheme Mark scheme for question 9(a)(ii)
(b)

The treasure game is being programmed using an object-oriented paradigm.

A class, Treasure, is used to store the treasure objects.

The design for the Treasure class, its attributes and methods is shown here.

Figure for question 9
(b)(i)

The constructor method takes a value as an integer, e.g. 100, and a level, e.g. "bronze", as parameters and assigns these to the attributes.

Write pseudocode or program code to declare the class Treasure.

You should define the attributes and constructor method in your answer.

You do not need to write the get methods.

[5]
Reveal mark scheme Mark scheme for question 9(b)(i)
(b)(ii)

The get method getLevel() will return the appropriate attribute.

Write the method getLevel() using either pseudocode or program code.

[2]
Reveal mark scheme Mark scheme for question 9(b)(ii)
(b)(iii)

Describe the object-oriented programming technique being used in part 9(b)(ii).

[2]
Reveal mark scheme Mark scheme for question 9(b)(iii)
(c)

A class, Board, is used to store the 10 row (x coordinate) by 20 column (y coordinate) grid.

The design for the Board class, its attributes and methods is shown here.

Figure for question 9

The constructor initialises each space in the grid to a treasure object with value as-1 and level as an empty string.

Complete the following pseudocode for the constructor method.

Figure for question 9
[5]
Reveal mark scheme Mark scheme for question 9(c)
(d)

A procedure, guessGrid():

• takes a Board object as a parameter

• accepts the row (x) and column (y) coordinates from the user

• outputs "No treasure" if there is no treasure found at the coordinate (level is an empty string)

• if there is treasure at that coordinate, it outputs the level and the value of the treasure in an appropriate message.

Write the procedure guessGrid() using either pseudocode or program code.

[7]
Reveal mark scheme Mark scheme for question 9(d)
(e)

Describe two benefits of using an object-oriented paradigm rather than a procedural paradigm.

[4]
Reveal mark scheme Mark scheme for question 9(e)
(f)

* The main program initialises a new instance of Board. The programmer is considering declaring this as a global variable or as a local variable and then passing this into the subroutines that control the game.

Compare the use of variables and parameters in this game.

You should include the following in your answer:

• what is meant by a local variable and global variable

• how local and global variables can be used in this program

• the use of passing parameters by value and by reference.

[9]
Reveal mark scheme Mark scheme for question 9(f)

Algorithms and programming June 2022, Question 4 9 marks

A programmer is developing an aeroplane simulator. The user will sit in a cockpit and the simulated environment will be displayed on screens around them.

(a)

The programmer uses computational methods to design a solution for the program.

(a)(i)

Complete the table by writing a definition for each computational method.

Figure for question 4
[2]
Reveal mark scheme Mark scheme for question 4(a)(i)
(a)(ii)

Give three potential differences between the abstracted aeroplane simulator and reality.

[3]
Reveal mark scheme Mark scheme for question 4(a)(ii)
(a)(iii)

Identify two reasons why abstraction is used when designing a solution to the problem.

[2]
Reveal mark scheme Mark scheme for question 4(a)(iii)
(b)

Describe how caching can be used in the aeroplane simulator.

[2]
Reveal mark scheme Mark scheme for question 4(b)

Algorithms and programming November 2021, Question 1 33 marks

Taylor is creating an online multiplayer game where users can create accounts and build their own circus. Each circus will contain characters such as clowns, animals, magicians and dancers.

Users can set up a new circus in the online world, purchase new characters and visit other users’ circuses.

(a)

Taylor uses computational methods to analyse the problem including abstraction.

Describe how Taylor could use abstraction in the design of his online circus game.

[3]
Reveal mark scheme Mark scheme for question 1(a)
(b)

Taylor will make use of concurrent processing within his circus game.

(b)(i)

Describe what is meant by the term ‘concurrent processing’.

[2]
Reveal mark scheme Mark scheme for question 1(b)(i)
(b)(ii)

Explain why concurrent processing is needed to allow multiple users to log in and interact with game elements at the same time.

[3]
Reveal mark scheme Mark scheme for question 1(b)(ii)
(c)

Some of the characters in the game will move and interact independently. Taylor is going to use graphs to plan the movements that each character can take within the game.

DancerGold is one character. The graph shown in Fig. 1 shows the possible movements that DancerGold can make.

Figure for question 1

DancerGold’s starting state is represented by node A. DancerGold can take any of the paths to reach the end state represented by node G.

The number on each path represents the number of seconds each movement takes.

The number in bold below each node is the heuristic value from A.

(c)(i)

Define the term heuristic in relation to the A* algorithm.

[2]
Reveal mark scheme Mark scheme for question 1(c)(i)
(c)(ii)

Perform an A* algorithm on the graph shown in Fig. 1 to find the shortest path from the starting node to the end node. Show your working, the nodes visited and the distance. You may choose to use the table below to give your answer.

Figure for question 1
[8]
Reveal mark scheme Mark scheme for question 1(c)(ii)
(d)

A breadth-first traversal can be performed on both a tree and a graph.

Show how a breadth-first traversal is performed on the following binary tree.

Figure for question 1
[6]
Reveal mark scheme Mark scheme for question 1(d)
(e)

* The game will have thousands of users. Taylor will store data about the users and their actions while playing the game in a large database.

Evaluate how Taylor can use data mining to inform future changes to improve his circus game.

[9]
Reveal mark scheme Mark scheme for question 1(e)

Algorithms and programming November 2020, Question 1 19 marks

Also involves Trees and binary search trees · Graphs (data structure)

Kira is creating a computer game where the user can play against the computer.

In each turn, each character can make one move from a selection of possible moves.

Kira uses a tree data structure shown in Fig. 1 to identify the range of possible moves the computer can make from starting position A. Each connection is a move, with each node representing the result of the move.

Figure for question 1
(a)

State what is meant by the term ‘abstraction’ and describe how Kira has used abstraction in her design of the tree.

[3]
Reveal mark scheme Mark scheme for question 1(a)
(b)

State why the tree shown in Fig. 1 is not an example of a binary search tree.

[1]
Reveal mark scheme Mark scheme for question 1(b)
(c)

State what type of pointers are used to store nodes I, F, J and H so they do not point to any other nodes.

[1]
Reveal mark scheme Mark scheme for question 1(c)
(d)

Kira wants the program to traverse the tree to evaluate the range of possible moves. She is considering using a breadth-first traversal or a depth-first (post-order) traversal.

Show how a breadth-first traversal would traverse the tree shown in Fig. 1.

[4]
Reveal mark scheme Mark scheme for question 1(d)
(e)

Kira wants to make some changes to the data that is stored in the tree structure shown in Fig. 1.

(e)(i)

The move represented by node ‘E’ needs to be deleted.

Describe the steps an algorithm will follow to delete node ‘E’ from the tree.

[3]
Reveal mark scheme Mark scheme for question 1(e)(i)
(e)(ii)

The move represented by the node ‘K’ needs to be added. Node ‘K’ needs to be joined to node ‘G.’

Describe the steps the algorithm will follow to add node ‘K’ to the right of node ‘G’.

[3]
Reveal mark scheme Mark scheme for question 1(e)(ii)
(f)

Kira could have used a graph data structure to represent the moves in her game.

Give two similarities and two differences between a tree and a graph data structure.

[4]
Reveal mark scheme Mark scheme for question 1(f)

Algorithms and programming June 2019, Question 7 40 marks

Figure for question 7
(a)

The programmer will use abstraction to produce the program interface to represent the garden.

(a)(i)

Give two different examples of how abstraction has been used to produce the layout of the garden.

[2]
Reveal mark scheme Mark scheme for question 7(a)(i)
(a)(ii)

Explain the need for abstraction in the production of this program.

[3]
Reveal mark scheme Mark scheme for question 7(a)(ii)
(a)(iii)

The user needs to input data into the program to set up their garden layout.

Identify three pieces of data that the user may input into this program.

[3]
Reveal mark scheme Mark scheme for question 7(a)(iii)
(b)

The program is to be built using object oriented programming.

All items that can be added to the garden are declared as instances of the class GardenItem

The class has the following attributes:

Figure for question 7
(b)(i)

The constructor method sets the attributes to values that are passed as parameters.

Write pseudocode or program code to declare the class GardenItem and its constructor. All attributes should be private and initialised through the constructor (e.g. daisies =

new GardenItem("Flowerbed",2,1) maths symbol

[4]
Reveal mark scheme Mark scheme for question 7(b)(i)
(b)(ii)

The trees in the garden layouts are defined by the class Tree. This class inherits from GardenItem.

The class Tree has the additional attributes: height, sun, shade.

If sun is true then the tree can grow in full sun, if it is false then it cannot.

If shade is true then the tree can grow in full shade, if it is false then it cannot.

The length and width of a tree are the same. Only one value for these measurements is passed to the constructor.

Write an algorithm, using pseudocode or program code, to declare the class Tree Declare all attributes as private.

[5]
Reveal mark scheme Mark scheme for question 7(b)(ii)
(b)(iii)

The Common Oak is a type of tree. It has a maximum height, length and width of 40 m. It can grow in sun and shade.

Write a statement, using pseudocode or program code, to declare an instance of tree for the Common Oak. Give the object the identifier firstTree.

[4]
Reveal mark scheme Mark scheme for question 7(b)(iii)
(b)(iv)

The classes GardenItem and Tree use get and set methods to access and alter their private attributes.

Write the get method getItemName and set method setItemName for class GardenItem. The set method takes the new value as a parameter.

Do not write any other methods, or re-declare the class.

[4]
Reveal mark scheme Mark scheme for question 7(b)(iv)
(b)(v)
Figure for question 7
[6]
Reveal mark scheme Mark scheme for question 7(b)(v)
(c)

* The programmer is designing the program to make use of caching and re-useable components.

Explain and evaluate the use of caching and re-useable components in the design of the garden program.

[9]
Reveal mark scheme Mark scheme for question 7(c)

Algorithms and programming June 2018, Question 3 27 marks

Also involves Trees and binary search trees · Graphs (data structure)

Figure for question 3
(a)

The graph in Fig. 3 is a visualisation of the problem.

(a)(i)

Identify one difference between a graph and a tree.

Figure for question 3
[1]
Reveal mark scheme Mark scheme for question 3(a)(i)
(a)(ii)

Explain how the graph is an abstraction of the problem.

Figure for question 3
[2]
Reveal mark scheme Mark scheme for question 3(a)(ii)
(a)(iii)

Identify two advantages of using a visualisation such as the one shown in Fig. 3.

Question 3, shown as an image
Question 3, shown as an image
[2]
Reveal mark scheme Mark scheme for question 3(a)(iii)
(b)

Demonstrate how Dijkstra’s algorithm would find the shortest path to the solution in Fig. 3.

Figure for question 3

maths symbol

[7]
Reveal mark scheme Mark scheme for question 3(b)
(c)

* The creator of the puzzle has been told that the A* algorithm is more efficient at finding the shortest path because it uses heuristics.

Compare the performance of Dijkstra’s algorithm and the A* search algorithm, making reference to heuristics, to find the shortest path to the problem.

Figure for question 3

maths symbol

[9]
Reveal mark scheme Mark scheme for question 3(c)
(d)
Figure for question 3 Figure for question 3 Figure for question 3
[6]
Reveal mark scheme Mark scheme for question 3(d)

Algorithms and programming June 2017, Question 6 40 marks

A software developer is creating a Virtual Pet game.

The user can choose the type of animal they would like as their pet, give it a name and then they are responsible for caring for that animal. The user will need to feed, play with, and educate their pet.

The aim is to keep the animal alive and happy, for example if the animal is not fed over a set period of time then the pet will die.

• The game tells the user how hungry or bored the animal is as a percentage (%) and the animal’s intelligence is ranked as a number between 0 and 150 (inclusive).

• Hunger and boredom increase by 1% with every tick of a timer.

• When the feed option is selected, hunger is reduced to 0.

• When the play option is selected, bored is reduced to 0.

• When the read option is selected, the intelligence is increased by 0.6% of its current value.

An example of the game is shown:

Figure for question 6

Fig. 1.1

(a)

Identify three inputs that the user will have to enter to start, and/or play the game.

[3]
Reveal mark scheme Mark scheme for question 6(a)
(b)

The developer is using decomposition to design the game.

(b)(i)

Describe the process of decomposition.

[2]
Reveal mark scheme Mark scheme for question 6(b)(i)
(b)(ii)
Figure for question 6
[6]
Reveal mark scheme Mark scheme for question 6(b)(ii)
(c)

The developer needs to write procedures for the options play and read. Each of the options changes its corresponding value, and outputs the results to the screen.

(c)(i)

Write a procedure, using pseudocode, to reset bored and output the new value in an appropriate message.

[3]
Reveal mark scheme Mark scheme for question 6(c)(i)
(c)(ii)

Write a procedure, using pseudocode, to increase intelligence by 0.6% and output the new intelligence in an appropriate message.

[3]
Reveal mark scheme Mark scheme for question 6(c)(ii)
(d)

The developer is extending the game to allow users to have multiple pets of different types. The developer has written a class, Pet.

The attributes and methods in the class are described in the table:

Figure for question 6

Part of the class declaration is given:

Figure for question 6
(d)(i)
Figure for question 6
[4]
Reveal mark scheme Mark scheme for question 6(d)(i)
(d)(ii)

Write a line of code that creates a new instance of Pet for a Tiger called “Springy”.

[2]
Reveal mark scheme Mark scheme for question 6(d)(ii)
(d)(iii)

The method outputGreeting for the superclass is written as follows:

Figure for question 6

A class is needed for Tiger. The class needs to:

• inherit the methods and attributes from pet

• in the constructor, set type to Tiger, intelligence to 10, hunger to 50 and bored to 10

• extend the method outputGreeting, by outputting an additional line that says “I like to eat meat and roar”

Write, using pseudocode, the class Tiger.

[5]
Reveal mark scheme Mark scheme for question 6(d)(iii)
(e)

(e*) The developer made use of abstraction when creating the Virtual Pet game.

Discuss the need for and purpose of abstraction and how abstraction will be used in the

development of the game.

[9]
Reveal mark scheme Mark scheme for question 6(e)
(f)

The developer is storing the user’s pets in a 1-dimensional array. At each timer interval, the array is searched, using a linear search, to check if any pets’ hunger or bored values are greater than 90%. If they are, an alert is displayed to the user.

(f)(i)

State the complexity of searching the pets in Big-O notation.

[1]
Reveal mark scheme Mark scheme for question 6(f)(i)
(f)(ii)

A given computer takes 4 milliseconds (ms) to search an array of 20 pets. Calculate an estimate of how long the computer will take to search an array of 100 pets.

Show your working.

[2]
Reveal mark scheme Mark scheme for question 6(f)(ii)

Report a problem with a question on this page
What is wrong?

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

Memes

Certified Computer Science memes. Peer-reviewed by nobody.

Laugh now. Cry in the exam hall later. Then come back and do a past paper.

Write a proper algorithm
Write ‘sort it’ and leave
Me on the 6-mark pseudocode question
Debugging with print statements
Using a trace table
Knowing the difference between = and ==
Explaining recursion by explaining recursion
Code enlightenment, ranked

Mum 💖

can you fix the wifi since you do computers 🥰

that's not what computer science is

so that's a no then

📱 Screen time this week · Discord8h 2m

Turned it off and on again

Computer Science starter pack

Laptop with 47 tabs openPython error on line 1Counting binary on fingersThis website
Compiled with zero errors