0% found this document useful (0 votes)
148 views4 pages

Depth - First - Traversal Exam Questions 2

Kira is creating a computer game where players can make moves. She uses a tree data structure to represent possible moves, but it is not a binary search tree. The tree can be traversed using breadth-first or depth-first traversal. Kira wants to delete node E and add node K connected to node G. Trees and graphs both represent relationships but trees have a root node and directed connections while graphs can have undirected connections and cycles. The tree uses child pointers to store orphan nodes. Abstraction refers to representing essential aspects without including implementation details, which Kira has done in her tree design.

Uploaded by

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

Depth - First - Traversal Exam Questions 2

Kira is creating a computer game where players can make moves. She uses a tree data structure to represent possible moves, but it is not a binary search tree. The tree can be traversed using breadth-first or depth-first traversal. Kira wants to delete node E and add node K connected to node G. Trees and graphs both represent relationships but trees have a root node and directed connections while graphs can have undirected connections and cycles. The tree uses child pointers to store orphan nodes. Abstraction refers to representing essential aspects without including implementation details, which Kira has done in her tree design.

Uploaded by

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

1(a). 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.

Fig. 1

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

[1]

(b). 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.

© OCR 2023. You may photocopy this


Page 1 of 4 Created in ExamBuilder
page.
[4]

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

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]

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]

(d). 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.

Similarity 1

Similarity 2

© OCR 2023. You may photocopy this


Page 2 of 4 Created in ExamBuilder
page.
Difference 1

Difference 2

[4]

(e). 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]

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

[3]

2. A program stores entered data in a binary search tree.

The current contents of the tree are shown:

Complete the diagram to show the contents of the tree after the following data is added:

© OCR 2023. You may photocopy this


Page 3 of 4 Created in ExamBuilder
page.
England, Scotland, Wales, Australia [3]

END OF QUESTION PAPER

© OCR 2023. You may photocopy this


Page 4 of 4 Created in ExamBuilder
page.

You might also like