Question 8
OCR Computer Science June 2024 Computer systems (H446-01)A level10 marks
On the specification
- (a)
- 1.4 Data types, data structures and algorithms
- (b)(i)
- 1.4 Data types, data structures and algorithms
- (b)(ii)
- 1.4 Data types, data structures and algorithms2.3 Algorithms
Question text
8 Fig. 8 shows a binary search tree that contains the names of different towns in Ireland. Fig. 8 Sligo Dublin Waterford Cork Galway Tralee Dundalk Limerick The binary search tree is held in a 2-dimensional array called towns with 8 rows and 3 columns. (a) Write a line of program code or pseudocode to declare the array towns. [2] (b) (i) In the 2-dimensional array towns: • the first column contains a pointer to the left side • the second column contains the data • the third column contains a pointer to the right side. Leaf nodes have the pointer null. Complete the table showing the contents of the towns array to store the binary search tree shown in Fig. 8. Left Data Right 0 Sligo 1 Dublin 2 Cork 3 Waterford 4 Galway 5 Limerick 6 Tralee 7 Dundalk [4] (ii) Four more towns are added to the binary search tree shown in Fig. 8 in this order: Mallow Cavan Tuam Wexford Complete this binary search tree by adding the new towns to it. Sligo Dublin Waterford Cork Galway Tralee Dundalk Limerick [4]