Question 3
AQA Computer Science June 2023 Paper 1 (7517/1)A level23 marks
On the specification
- 3.1
- 4.2 Fundamentals of data structures
- 3.2
- 4.2 Fundamentals of data structures4.3 Fundamentals of algorithms
- 3.3
- 4.3 Fundamentals of algorithms
- 3.4
- 4.3 Fundamentals of algorithms4.4 Theory of computation
- 3.5
- 4.4 Theory of computation
- 3.6
- 4.4 Theory of computation
- 3.7
- 4.4 Theory of computation
Question text
3 A binary tree is a type of data structure. 3.1 State two characteristics that make a tree a binary tree. [2 marks] 3.2 Figure 2 shows a binary tree and its representation using an array of records called Tree. Each record consists of three fields, Data, Left and Right. Figure 2 Data Left Right [0] 6 1 4 [1] 3 2 3 [2] 1 -1 -1 [3] 4 -1 -1 [4] 9 -1 -1 Figure 3 shows a subroutine that implements a binary tree search algorithm using the array Tree. The subroutine parameter, k, is the data item being searched for. The subroutine returns a Boolean value indicating if the data item being searched for is in the binary tree or not. Parts of the algorithm are missing. Figure 3 SUBROUTINE BTS(k) Current 1 WHILE Current > 2 IF Tree[Current].Data = k THEN RETURN 3 ELSEIF Tree[Current].Data < k THEN 4 ELSE 5 ENDIF ENDWHILE RETURN 6 ENDSUBROUTINE Complete each row in Table 1, to show what the labels indicating missing parts of the algorithm in Figure 3 should be replaced by. Table 1 1 2 3 4 5 6 Copy the contents of the unshaded cells in Table 1 into the table in your Electronic Answer Document. [4 marks] 3.3 There are similarities in how the binary tree search and the binary search algorithms work. State the big-O time complexity of the binary search algorithm. [1 mark] 3.4 Explain why the binary search algorithm has the time complexity stated in your answer for 03.3. [1 mark] 3.5 Explain why searching for an item in a list or tree is a tractable problem. [1 mark] 3.6 Heuristics can be used when working with an intractable problem. Explain what heuristics are. [2 marks] 3.7 Explain what is meant by constant time complexity. [2 marks]