Question 2(d)(i) 2017 · May-June · Paper 42 · 7 marks
Reveal official mark-scheme answer
Official answer for Question 2
Part (d)
(i)
Question 7
Question 1
Question 1
Question 1
Question 1
Question 1
Question 1
Question 1
Show text version of question
Question 2
Part (d)
(i)
Question 2
An ordered binary tree Abstract Data Type (ADT) has these associated operations:
- create tree
- add new item to tree
- traverse tree
The binary tree ADT is to be implemented as a linked list of nodes.
Each node consists of data, a left pointer and a right pointer.
used are listed below:
Identifier Data type Description Data structure to store node data and associated Node RECORD pointers. LeftPointer INTEGER Stores index of start of left subtree. RightPointer INTEGER Stores index of start of right subtree. Data STRING Data item stored in node. Tree ARRAY Array to store nodes. NewDataItem STRING Stores data to be added. FreePointer INTEGER Stores index of start of free list. RootPointer INTEGER Stores index of root node. NewNodePointer INTEGER Stores index of node to be added. Procedure initialises the root pointer and free pointer CreateTree() and links all nodes together into the free list. Procedure to add a new data item in the correct AddToTree() position in the binary tree. Procedure that finds the node where a new node is to be added. Procedure takes the parameter NewDataItem and returns two parameters: FindInsertionPoint()
- Index, whose value is the index of the node
- Direction, whose value is the direction of the
where the new node is to be added
pointer (“Left” or “Right”).
Question 7
(i)
Complete the pseudocode to create an empty tree.
TYPE Node
.....................................................................................................................................
.....................................................................................................................................
.....................................................................................................................................
ENDTYPE
DECLARE Tree : ARRAY[0 : 9] ................................................................................
DECLARE FreePointer : INTEGER
DECLARE RootPointer : INTEGER
PROCEDURE CreateTree()
DECLARE Index : INTEGER
.....................................................................................................................................
.....................................................................................................................................
FOR Index ← 0 TO 9 // link nodes
..............................................................................................................................
..............................................................................................................................
ENDFOR
.....................................................................................................................................
ENDPROCEDURE
Question 8
Why this question appears here
71% assigned-topic match · Data types and structures › Arrays
Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.
Permanent source page: Educate A Change · From 9608_s17_qp_42.pdf
