Question 2
OCR Computer Science June 2022 Algorithms and programming (H446-02)A level16 marks
On the specification
- (a)
- 1.4 Data types, data structures and algorithms
- (b)
- 1.4 Data types, data structures and algorithms
- (c)
- 1.4 Data types, data structures and algorithms2.3 Algorithms
- (d)
- 2.3 Algorithms
Question text
2 A computer program is being written to store data about students. Fig. 2 shows a binary search tree that stores data about students. Each student is represented by their ID number. The current contents of the binary search tree are: 2005 1920 2350 1500 1985 2100 2560 1952 2000 Fig. 2 (a) Identify the root node in the binary tree shown in Fig. 2. [1] (b) Identify two leaf nodes in the binary tree shown in Fig. 2. 1 2 [2] (c) Four more students are added to the binary search tree shown in Fig. 2 in this order: 1420 2050 2780 2600 Complete the binary search tree here by adding the new students to it. 2005 1920 2350 1500 1985 2100 2560 1952 2000 [4] (d)* A programmer would like to traverse the binary search tree shown in Fig. 2. Compare the use of a breadth-first traversal and a depth-first (post-order) traversal on the binary search tree. You should include the following in your answer: • how each traversal works • the order of the return values for each traversal. [9]