Question 7
AQA Computer Science June 2019 Paper 1A level10 marks
On the specification
- 7.1
- 3.1 Fundamentals of programming
- 7.2
- 3.1 Fundamentals of programming
- 7.3
- 4.3 Fundamentals of algorithms
- 7.4
- 4.3 Fundamentals of algorithms
- 7.5
- 4.2 Fundamentals of data structures
- 7.6
- 4.2 Fundamentals of data structures
Question text
7 The GetIndexOfItem subroutine is used to find the position of an item in Items. The item to find can be specified using either its name or its ID. 7.1 Explain what it means if a value of -1 is returned by GetIndexOfItem. [1 mark] 7.2 How does the subroutine GetIndexOfItem know if it should try to find the item using the name or the ID passed to it as parameters? [1 mark] 7.3 What is the time complexity of the algorithm used to find an item in the GetIndexOfItem subroutine? [1 mark] 7.4 There is an error in the code for the Skeleton Program that does not cause a problem when using the data in the game files provided but could cause a problem with alternative game files. Under what circumstances will the GetIndexOfItem subroutine return the index of an item that was not the item being searched for? [2 marks] If the Skeleton Program had been designed to use a hash table to store the items it is likely that it would be able to find the position of an item, when given its ID, in less time than the algorithm currently used in the subroutine GetIndexOfItem. 7.5 Explain the steps involved in finding an item in the hash table. You should assume that all the items available in the game have already been successfully added into the hash table. [4 marks] 7.6 Give one reason why a hash table is not a suitable choice to store the items in the Skeleton Program. [1 mark]