Question 7
AQA Computer Science June 2017 Paper 1A level14 marks
On the specification
- 7.1
- 3.1 Fundamentals of programming
- 7.2
- 4.13 Systematic approach to problem solving
- 7.3
- 4.13 Systematic approach to problem solving
Question text
7 One method that can be used to compress text data is run length encoding (RLE). When RLE is used the compressed data can be represented as a set of character/frequency pairs. When the same character appears in consecutive locations in the original text it is replaced in the compressed text by a single instance of the character followed by a number indicating the number of consecutive instances of that character. Single instances of a character are represented by the character followed by the number 1. Figure 9 and Figure 10 show examples of how text would be compressed using this method. Figure 9 Original text: AAARRRRGGGHH Compressed text: A 3 R 4 G 3 H 2 Figure 10 Original text: CUTLASSES Compressed text: C 1 U 1 T 1 L 1 A 1 S 2 E 1 S 1 What you need to do Task 1 Write a program that will perform the compression process described above. The program should display a suitable prompt asking the user to input the text to compress and then output the compressed text. Task 2 Test the program works by entering the text AAARRRRGGGHH. Task 3 Test the program works by entering the text A. Evidence that you need to provide Include the following in your Electronic Answer Document. 7.1 Your PROGRAM SOURCE CODE. [12 marks] 7.2 SCREEN CAPTURE(S) for the test showing the output of the program when AAARRRRGGGHH is entered. [1 mark] 7.3 SCREEN CAPTURE(S) for the test showing the output of the program when A is entered. [1 mark] You are advised to spend no more than 15 minutes on this section. Type your answers to Section C into your Electronic Answer Document. You must save this document at regular intervals. These questions refer to the Preliminary Material and the Skeleton Program, but do not require any additional programming. Refer either to the Preliminary Material issued with this question paper or your electronic copy.