Question 1
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.
State what is meant by the term ‘abstraction’ and describe how Kira has used abstraction in her design of the tree.
[3]
State why the tree shown in Fig. 1 is not an example of a binary search tree.
[1]
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]
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]
Kira wants to make some changes to the data that is stored in the tree structure shown in Fig. 1.
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]
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]
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]