Question 2
OCR Computer Science June 2019 Paper 1A level11 marks
On the specification
- (a)
- 1.3 Exchanging data
- (b)
- 1.3 Exchanging data
- (c)
- 1.3 Exchanging data
- (d)
- 2.2 Problem solving and programming
Question text
2 A survey is carried out to look at the types of vehicle that travel down a stretch of motorway. For each vehicle that passes by, a letter is entered into the system. For a car ‘C’ is entered. For a motorbike ‘M’ is entered. For a lorry ‘L’ is entered. For any other vehicle ‘O’ is entered. It is decided to compress the data that has been generated. (a) State what is meant by the term ‘compression’. [1] It is decided that Run Length Encoding will be used. (b) The following sequence has been compressed using Run Length Encoding. 3C3M4C Show the result of decompressing the sequence. [2] (c) Show the result of using Run Length Encoding to compress the sequence: CCCCOLLLCCCCCMOCCCCC [3] The survey takers want to find out the longest continuous sequence of cars in any given chunk of data. For example, in the data CCMCCCCLLCCC the longest sequence would be 4. (d) Write the function longest which takes in a string of characters as an argument and returns an integer representing the longest continuous sequence of Cs. [5]