Revision Library
Choose a subject
Menu
Computer Science
Need a new topic?
Missing a topic, found a bug, or want something added?

GCSE Computer Science Topic Workbooks · Book 2 of 2

GCSE Computer Science Topic Workbook 2

Producing Robust Programs, Boolean Logic, Data Representation: Number Systems and 6 more

Level
GCSE · AQA 8525 · OCR J277
Series
GCSE Computer Science Topic Workbooks, book 2 of 2
Suitable for
Years 10-11, AQA / OCR
FreePDF download · 2027 edition · 109 A4 pages
  • One file, prints straight to A4
  • No account, no password

Workbooks like this one, with 9 topics, 137 questions and mark schemes at the back, are usually printed and sold by publishers. This one is one of 558 free PDFs on the shelf.

Pages
109 A4 pages
Chapters
9 worksheet chapters
Questions
137 · 606 marks
Answers
From page 86
Working time
About 11h 40m

What is inside

9 chapters · answers from p86

Each chapter starts with a page showing its marks and a suggested time, followed by the questions. The mark schemes for all 9 chapters are at the back, so the book works for homework, a timed test or revision.

  1. 01Producing Robust Programs15 questions · 70 marks · about 80 min Topic guide: Producing Robust Programsp3
  2. 02Boolean Logic15 questions · 65 marks · about 75 min Topic guide: Boolean Logicp13
  3. 03Data Representation: Number Systems15 questions · 65 marks · about 75 min Topic guide: Data Representation: Number Systemsp25
  4. 04Data Representation: Images, Sound and Compression15 questions · 82 marks · about 95 min Topic guide: Data Representation: Images, Sound and Compressionp33
  5. 05Programming Practice: Writing and Refining Programs15 questions · 69 marks · about 80 min Topic guide: Programming Practice: Writing and Refining Programsp43
  6. 06SQL and Data Handling13 questions · 56 marks · about 65 min Topic guide: SQL and Data Handlingp52
  7. 07Trace Tables and Binary/Hex Conversions18 questions · 82 marks · about 95 min Topic guide: Trace Tables and Binary/Hex Conversionsp60
  8. 08Translators and Integrated Development Environments (IDEs)15 questions · 55 marks · about 65 min Topic guide: Translators and Integrated Development Environments (IDEs)p71
  9. 091D and 2D Array Processing: Writing and Tracing Programs16 questions · 62 marks · about 70 min Topic guide: 1D and 2D Array Processing: Writing and Tracing Programsp77
  10. AnswersMark schemes for every chapterp86

Each chapter is drawn from one of our worksheet packs. Follow a chapter title for the full pack on its own page, or browse every GCSE Computer Science pack. Every book on the shelf is a complete printable workbook of up to 120 A4 pages.

Explore this volume

GCSE Computer Science Topic Workbook 2 includes Producing Robust Programs (from page 3); Boolean Logic (from page 13); Data Representation: Number Systems (from page 25); Data Representation: Images, Sound and Compression (from page 33); Programming Practice: Writing and Refining Programs (from page 43); SQL and Data Handling (from page 52); Trace Tables and Binary/Hex Conversions (from page 60); Translators and Integrated Development Environments (IDEs) (from page 71); 1D and 2D Array Processing: Writing and Tracing Programs (from page 77).

Worked question 15 - Programming Practice: Writing and Refining Programs

Open the included worksheet

A shop stores its stock data in a text file called "stock.txt". The file lists each item on its own line, followed immediately by its quantity on the next line, repeated for every item, for example:
Kettle
14
Toaster
3

Write a program that:
- reads all the stock data from "stock.txt" into two parallel arrays, itemNames and quantities, keeping track of how many items were read in a variable itemCount
- includes a function called findItem that takes itemNames, itemCount and a search name as parameters, and returns the index of the item, or -1 if not found
- asks the user to input an item name to check
- uses findItem to look up the item and outputs its quantity, or a suitable message if the item is not found
- if the item is found and its quantity is less than 5, additionally outputs a low stock warning

Answer and mark scheme

Question 15

CreditAnswer or working
B1correct file opened for reading and a condition-controlled loop that reads until WHILE NOT EOF(stockFile) becomes false
B1correct reading of a name line then a quantity line (cast to an integer with INT()) inside the loop, storing each into the respective array at index itemCount and incrementing itemCount (oe; accept declared fixed-size arrays with a running counter, or any other correct method of building the two arrays)
B1correct findItem function header taking the array, itemCount and searchName as parameters
B1correct iteration (e.g. FOR i = 0 TO itemCount - 1) and selection returning the matching index i inside the loop
B1correct RETURN of -1 placed after the loop, only reached if no match was found
B1correct INPUT for the search name, and a call to findItem storing the result in a variable
B1correct selection: IF index == -1 THEN a not-found message is output, ELSE quantities[index] is output
B1correct nested check, quantities[index] < 5, correctly nested inside the found branch, outputting a low stock warning when true
  • Answer:
    itemCount = 0
    DECLARE itemNames : ARRAY[0:49] OF STRING
    DECLARE quantities : ARRAY[0:49] OF INTEGER
    stockFile = OPENFILE("stock.txt", READ)
    WHILE NOT EOF(stockFile)
        itemNames[itemCount] = READFILE(stockFile)
        quantities[itemCount] = INT(READFILE(stockFile))
        itemCount = itemCount + 1
    ENDWHILE
    CLOSEFILE(stockFile)
    FUNCTION findItem(itemNames, itemCount, searchName)
        FOR i = 0 TO itemCount - 1
            IF itemNames[i] == searchName THEN
                RETURN i
            ENDIF
        NEXT i
        RETURN -1
    ENDFUNCTION
    
    INPUT searchName
    index = findItem(itemNames, itemCount, searchName)
    IF index == -1 THEN
        OUTPUT "Item not found"
    ELSE
        OUTPUT quantities[index]
        IF quantities[index] < 5 THEN
            OUTPUT "Low stock warning"
        ENDIF
    ENDIF

Question 14 - Programming Practice: Writing and Refining Programs

Open the included worksheet

A text file called "results.txt" contains one exam mark (an integer out of 100) per line, for every student in a class. Write an algorithm that reads every mark from "results.txt", and writes only the marks that are 40 or above to a new file called "pass.txt", with one mark per line. The algorithm should output the total number of passing marks written.

Answer and mark scheme

Question 14

CreditAnswer or working
B1correct read file opened for reading, e.g. inFile = OPENFILE("results.txt", READ)
B1correct write file opened for writing, e.g. outFile = OPENFILE("pass.txt", WRITE)
B1a count variable initialised to 0 before the loop
B1correct condition-controlled loop reading each line WHILE NOT EOF(inFile), casting each value to an integer with INT()
B1correct selection testing mark ≥ 40 and, when true, writing the mark to outFile using WRITEFILE (with STR() to cast back to a string) and incrementing count
B1both files closed with CLOSEFILE after the loop, and count output (oe; accept close statements in either order, provided both files are closed)
  • Answer:
    inFile = OPENFILE("results.txt", READ)
    outFile = OPENFILE("pass.txt", WRITE)
    count = 0
    WHILE NOT EOF(inFile)
        mark = INT(READFILE(inFile))
        IF mark >= 40 THEN
            WRITEFILE(outFile, STR(mark))
            count = count + 1
        ENDIF
    ENDWHILE
    CLOSEFILE(inFile)
    CLOSEFILE(outFile)
    OUTPUT count

Question 11 - Programming Practice: Writing and Refining Programs

Open the included worksheet

An array called names stores the names of students in a class:
names = ["Priya", "Oliver", "Fatima", "Callum", "Grace"]

Write a function called findStudent that takes the array names and a string searchName as parameters, and returns the index of searchName in the array if found, or -1 if the name is not found.

Answer and mark scheme

Question 11

CreditAnswer or working
B1correct FUNCTION header taking both the array and the search name as parameters, e.g. FUNCTION findStudent(names, searchName)
B1correct iteration through every index of the array (e.g. FOR i = 0 TO LEN(names) - 1, oe)
B1correct selection comparing the current array element to searchName, e.g. IF names[i] == searchName THEN
B1correct RETURN of the current index i inside the loop when a match is found
B1correct RETURN of -1 placed after the loop, only reached when no match has been found
  • Answer:
    FUNCTION findStudent(names, searchName)
        FOR i = 0 TO LEN(names) - 1
            IF names[i] == searchName THEN
                RETURN i
            ENDIF
        NEXT i
        RETURN -1
    ENDFUNCTION

Question 15 - Data Representation: Images, Sound and Compression

Open the included worksheet

A video call application sends both image frames and sound at the same time.
Each video frame is 640 x 480 pixels with a colour depth of 16 bits per pixel. The application sends 2 frames every second.
The sound is sampled at 8000 Hz with a bit depth of 16 bits, recorded in stereo (2 channels).
(a)Calculate the number of bits needed to store one uncompressed video frame.(2)
(b)Calculate the total number of bits of video data sent in one second, given that 2 frames are sent per second.(1)
(c)Calculate the number of bits of sound data generated in one second.(2)
(d)Calculate the total combined number of bits per second (video and sound together) that the application must transmit, and hence explain why real-time video calls almost always use compression.(3)

Answer and mark scheme

Question 15

CreditAnswer or working
M1(a) correct method: 640 x 480 x 16 (oe)
A1(a) 4915200 (bits) cao
B1(b) 9830400 (bits per second) cao ft (their part a x 2)
M1(c) correct method: 8000 x 16 x 2 (oe)
A1(c) 256000 (bits) cao
M1(d) adds video and sound data rates together: (their part b) + (their part c) (oe, ft)
A1(d) 10086400 (bits per second) cao ft
B1(d) explains that compression reduces the bandwidth required, helping avoid congestion and delays on connections with limited available bandwidth (oe)
  • (a) Answer: 4 915 200 bits
  • (b) Answer: 9 830 400 bits per second
  • (c) Answer: 256 000 bits per second
  • (d) Answer: 10 086 400 bits per second; compression reduces the bandwidth required and helps avoid congestion and delays on connections with limited available bandwidth.

Question 13 - Data Representation: Images, Sound and Compression

Open the included worksheet

A file contains only the following characters, with these frequencies:
E: 8 T: 5 A: 3 O: 2
A Huffman tree is to be built to assign binary codes to each character, with the most frequent characters given the shortest codes.
(a)Describe the general method used to build a Huffman tree from a frequency table.(3)
(b)Using the frequencies given, calculate the total number of bits needed to store the whole file if a fixed-length binary code were used for every character instead of Huffman coding.(3)

Answer and mark scheme

Question 13

CreditAnswer or working
B1(a) repeatedly combine/merge the two nodes (symbols, or previously combined nodes) with the lowest frequencies into a new node (oe)
B1(a) the new node's frequency is the sum of the two combined frequencies; this is repeated until only one node (the root) remains (oe)
B1(a) starting from the root, a 0 or 1 is assigned to each branch to build the binary code for each character; characters that are fewer branches from the root (more frequent) end up with shorter codes (oe)
M1(b) recognises that 4 different characters need 2 bits each for a fixed-length code, since 22 = 4 (oe)
M1(b) finds the total number of characters in the file: 8 + 5 + 3 + 2 = 18 (oe)
A1(b) 36 (bits) cao
  • (a) Answer: Repeatedly merge the two lowest-frequency nodes into a new node whose frequency is their sum, until one root node remains; then assign 0/1 to each branch from the root to generate each character's code, giving more frequent characters shorter codes.
  • (b) Answer: 36 bits

GCSE Computer Science Topic Workbooks runs to 2 volumes

Book 2 of 2 · 223 pages in the set

Each book is a separate free PDF.

Volume 1

114 pp · 160 Qs

Systems Architecture, Memory and Primary Storage, Secondary Storage and 7 more

Volume 2 · this book

109 pp · 137 Qs

Producing Robust Programs, Boolean Logic, Data Representation: Number Systems and 6 more

More GCSE books

Want a different mix of topics?

Sitting an exam soon? Build a GCSE Computer Science mock paper or print a ready-made one.