Question 2

OCR Computer Science Specimen Paper 1A level14 marks

On the specification

(a)
1.4 Data types, data structures and algorithms
(b)(i)
2.2 Problem solving and programming1.4 Data types, data structures and algorithms
(b)(ii)
1.4 Data types, data structures and algorithms
(c)
2.2 Problem solving and programming1.4 Data types, data structures and algorithms
Question text

2 Atlas Airlines runs flights across cities in Europe. It stores the prices of different flights in its computer system. (a) State a data structure that would be suited to represent the data above. [1] (b) A function tripCost has been written that takes in two cities and returns the price of a direct flight between them. e.g. tripCost("Dublin", "London") returns 90. A journey is represented by an array called cities. An example of a trip from Dublin to Rome is shown below: Dublin London Paris Rome (i) Write a program in the language or pseudocode of your choice that uses the cities array to calculate and output the cost of a given journey as a monetary value. In the case above this would be £950. [5] (ii) Rather than storing cities in an array you could use a linked list. Describe a difference between an array and a linked list. [2] (c) Each airport has a three letter code. The airline’s system stores the airports and corresponding airport codes: Code Name Barcelona BCN International DUB Dublin LIS Lisbon London LHR Heathrow Paris, CDG Charles De Gaulle PRG Prague RKV Reykjavik Rome, FCO Fiumicino In a programming language or pseudocode of your choice write a program that takes in an airport code and finds and displays the airport name. You can assume a 2D array called airports has already been declared and populated with the data above. There is no need to validate the input and you can assume that the user will only enter a code that exists in the array. [6]