Question 2
OCR Computer Science June 2017 Paper 2A level35 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 algorithms
- (c)(i)
- 1.4 Data types, data structures and algorithms
- (c)(ii)
- 2.2 Problem solving and programming1.4 Data types, data structures and algorithms
- (c)(iii)
- 2.2 Problem solving and programming1.4 Data types, data structures and algorithms
- (c)(iv)
- 1.4 Data types, data structures and algorithms
- (d)
- 2.3 Algorithms
- (e)
- 2.2 Problem solving and programming
- (f)
- 2.1 Elements of computational thinking
Question text
2 A programmer is developing an ordering system for a fast food restaurant. When a member of staff inputs an order, it is added to a linked list for completion by the chefs. (a) Explain why a linked list is being used for the ordering system. [2] (b) Each element in a linked list has: • a pointer, nodeNo, which gives the number of that node • the order number, orderNo • a pointer, next, that points to the next node in the list Fig. 2.1 shows the current contents of the linked list, orders. nodeNo orderNo next 0 154 1 1 157 2 2 155 3 3 156 ∅ Fig. 2.1 ∅ represents a null pointer. (i) Order 158 has been made, and needs adding to the end of the linked list. Add the order, 158, to the linked list as shown in Fig. 2.1. Show the contents of the linked list in the following table. nodeNo orderNo next [2] (ii) Order 159 has been made. This order has a high priority and needs to be the second order in the linked list. Add the order, 159, to the original linked list as shown in Fig. 2.1. Show the contents of the linked list in the following table. nodeNo orderNo next [3] (c) The linked list is implemented using a 2D array, theOrders: • Row 0 stores orderNo • Row 1 stores next The data now stored in theOrders is shown in Fig. 2.2. 184 186 185 187 12 3 Fig. 2.2 theOrders[1,0] would return 1 The following algorithm is written: procedure x() finished = false count = 0 while NOT(finished) if theOrders[1,count] == null then finished = true else output = theOrders[0,count] print(output) count = theOrders[1,count] endif endwhile output = theOrders[0,count] print(output) endprocedure (i) Outline why nodeNo does not need to be stored in the array. [1] (ii) Complete the trace table for procedure x, for the data shown in Fig. 2.2. finished count output [3] (iii) Describe the purpose of procedure x. [2] (iv) A new order, 190, is to be added to theOrders. It needs to be the third element in the list. The current contents of the array are repeated here for reference: 184 186 185 187 12 3 Describe how the new order, 190, can be added to the array, so the linked list is read in the correct order, without rearranging the array elements. [4] (d) The user needs to be able to search for, and find, a specific order number. State an appropriate search algorithm that could be used, and justify your choice against an alternative Search algorithm. Appropriate Search Algorithm Justification [3] (e) The programmer is writing the program using an IDE. Identify three features of an IDE that the programmer would use when writing the code and describe how the features benefit the programmer. 1 2 3 [6] (f*) The programmer is considering using concurrent programming. Discuss how concurrent programming can be applied to the food ordering system and the benefits and limitations of doing so. [9]