Trace Tables and Binary/Hex Conversions - Worksheets, Questions and Revision
18 original exam-style questions - 10 pages of questions with a full mark scheme - free printable PDF.
Trace Tables and Binary/Hex Conversions revision guideMore GCSE Computer Science practiceMock exams
This topic is chapter 7 of GCSE Computer Science Topic Workbook 2 and chapter 16 of GCSE Computer Science 10-Minute Tests.
2.9 Trace Tables and Binary/Hex Conversions
total <- 0
FOR count <- 1 TO 5
total <- total + (count * 2)
NEXT count
OUTPUT total| count | total |
|---|---|
| (start) | 0 |
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 |
OUTPUT =(6)
numbers <- [4, 9, 2, 7, 5]
largest <- numbers[0]
FOR index <- 1 TO 4
IF numbers[index] > largest THEN
largest <- numbers[index]
ENDIF
NEXT index
OUTPUT largest| index | numbers[index] | largest |
|---|---|---|
| (start) | - | 4 |
| 1 | ||
| 2 | ||
| 3 | ||
| 4 |
OUTPUT =(6)
number <- 100
count <- 0
WHILE number > 1
number <- number DIV 2
count <- count + 1
ENDWHILE
OUTPUT count| number | count |
|---|---|
| 100 (start) | 0 |
| | | |
| | | |
| | | |
| | | |
| | |
OUTPUT =(7)
number <- 44
binaryDigits <- ""
WHILE number > 0
remainder <- number MOD 2
binaryDigits <- STR(remainder) + binaryDigits
number <- number DIV 2
ENDWHILE
OUTPUT binaryDigits| remainder | binaryDigits | number |
|---|---|---|
| - | "" | 44 (start) |
OUTPUT =(9)
Question 1
- (a) Correct place values selected that total 122 (64, 32, 16, 8, 2), oeM1
- (a) 01111010, caoA1
- (a) Answer: 01111010
- (b) Correct place values selected that total 201 (128, 64, 8, 1), oeM1
- (b) 11001001, caoA1
- (b) Answer: 11001001
Question 2
- (a) correct offset identified, e.g. 'M' is the 13th letter of the alphabet, so the offset from 'A' is 12, oeM1
- (a) 77, caoA1
- (a) Answer: 77
- (b) 6 characters identified and multiplied by 8 bits, oeM1
- (b) 48, caoA1
- (b) Answer: 48 bits
Question 3
- (a) Binary split into two correct nibbles: 1011 and 0101, oeM1
- (a) B5, caoA1
- (a) Answer: B5
- (b) Binary split into two correct nibbles: 0111 and 1110, oeM1
- (b) 7E, caoA1
- (b) Answer: 7E
Question 4
- (a) Each hex digit correctly converted to a 4 bit nibble: 3 = 0011, A = 1010, oeM1
- (a) 00111010, caoA1
- (a) Answer: 00111010
- (b) Each hex digit correctly converted to a 4 bit nibble: F = 1111, 4 = 0100, oeM1
- (b) 11110100, caoA1
- (b) Answer: 11110100
Question 5
- (a) hexadecimal is much shorter/more compact to write than binary for the same value, oeB1
- (a) each hex digit represents exactly one nibble (4 bits), so conversion between binary and hex is quick and direct, and hex is easier for humans to read/less error-prone to transcribe than long strings of 0s and 1s, oeB1
- (a) valid real-world example, e.g. MAC addresses, HTML colour codes, memory addresses/locations (any suitable example)B1
- (a) Answer: Hex is shorter and easier to read than binary, and each digit maps directly to 4 bits, e.g. it is used for MAC addresses or HTML colour codes.
Question 6
- (a) correct method shown, e.g. (2 x 16) + 15, oeM1
- (a) 47, caoA1
- (a) Answer: 47
- (b) correct method shown, e.g. 200 DIV 16 = 12 remainder 8, oeM1
- (b) C8, caoA1
- (b) Answer: C8
Question 7
- (a) correct shifting process shown, e.g. bits moved two places left, two 0s inserted on the right, oeM1
- (a) 00110100, caoA1
- (a) Answer: 00110100
- (b) before = 13, after = 52, both correct, oeB1
- (b) a left shift by n places multiplies the value by 2n (here, shifting left by 2 multiplies by 4), provided no significant bits are lost off the left hand end, oeB1
- (b) Answer: Before = 13, after = 52; a left shift by n places multiplies the value by 2n.
Question 8
- (a) correct shifting process shown, e.g. bits moved three places right, three 0s inserted on the left, oeM1
- (a) 00011010, caoA1
- (a) Answer: 00011010
- (b) before = 208, after = 26, both correct, oeB1
- (b) a right shift by n places divides the value by 2n (integer division), here dividing by 8; any bits shifted off the right hand end are lost/discarded, oeB1
- (b) Answer: Before = 208, after = 26; a right shift by n places divides the value by 2n.
Question 9
- (a) standard ASCII only has enough bits to represent a limited number of characters (128 with 7 bits), which is not enough to cover every character used in every language and symbol set, oeB1
- (a) Unicode uses more bits per character, so it can represent a much larger number of unique characters, covering characters from many different languages and other symbols such as emoji, oeB1
- (a) Answer: ASCII cannot represent enough characters for every language; Unicode uses more bits per character, allowing far more characters to be represented.
- (b) 16 - 7 shown as the method, oeM1
- (b) 9, caoA1
- (b) Answer: 9 more bits per character
Question 10
- (a) count = 1: total = 2, caoB1
- (a) count = 2: total = 6, caoB1
- (a) count = 3: total = 12, caoB1
- (a) count = 4: total = 20, caoB1
- (a) count = 5: total = 30, caoB1
- (a) OUTPUT = 30, caoB1
- (a) Answer: total: 2, 6, 12, 20, 30; OUTPUT = 30
Question 11
- (a) correct column-by-column addition process shown, with at least one correct carry, oeM1
- (a) 01111111, caoA1
- (a) no overflow occurs, because the true sum (127) fits within the range of an unsigned 8 bit number (0 to 255), oeB1
- (a) Answer: 01111111, no overflow
Question 12
- (a) correct column-by-column addition process shown, with correct carries propagated, oeM1
- (a) 00001011, caoA1
- (a) Answer: 00001011
- (b) overflow occurs because the true sum, 267, is greater than 255, the maximum value that can be stored in an unsigned 8 bit register, oeB1
- (b) the extra carry out of the most significant bit (bit 7) cannot be stored in an 8 bit register, so it is lost/discarded, meaning the stored result no longer represents the correct total, oeB1
- (b) Answer: 267 exceeds the 8 bit maximum of 255, so the carry out of bit 7 is lost and the register stores an incorrect, wrapped-round value.
Question 13
- (a) 77 correctly converted to 8 bit binary: 01001101, oeM1
- (a) all bits correctly inverted: 10110010, oeM1
- (a) 10110011, cao (1 added to the inverted bits)A1
- (a) Answer: 10110011
Question 14
- (a) bits correctly inverted: 00010110, oeM1
- (a) 1 correctly added to the inverted bits: 00010111 (=23), oeM1
- (a) -23, caoA1
- (a) Answer: -23
Question 15
- (a) numbers[index] column correct throughout: 9, 2, 7, 5, oeB1
- (a) index = 1: largest = 9, cao (9 > 4 is true)B1
- (a) index = 2: largest remains 9, cao (2 > 9 is false)B1
- (a) index = 3: largest remains 9, cao (7 > 9 is false)B1
- (a) index = 4: largest remains 9, cao (5 > 9 is false)B1
- (a) OUTPUT = 9, caoB1
- (a) Answer: largest: 9, 9, 9, 9; OUTPUT = 9
Question 16
- (a) number = 50, count = 1, caoB1
- (a) number = 25, count = 2, caoB1
- (a) number = 12, count = 3, caoB1
- (a) number = 6, count = 4, caoB1
- (a) number = 3, count = 5, caoB1
- (a) number = 1, count = 6, caoB1
- (a) OUTPUT = 6, cao (loop ends because number is no longer greater than 1)B1
- (a) Answer: number: 50,25,12,6,3,1; count: 1,2,3,4,5,6; OUTPUT = 6
Question 17
- (a) iteration 1: remainder = 0, binaryDigits = "0", number = 22, caoB1
- (a) iteration 2: remainder = 0, binaryDigits = "00", number = 11, caoB1
- (a) iteration 3: remainder = 1, binaryDigits = "100", number = 5, caoB1
- (a) iteration 4: remainder = 1, binaryDigits = "1100", number = 2, caoB1
- (a) iteration 5: remainder = 0, binaryDigits = "01100", number = 1, caoB1
- (a) iteration 6: remainder = 1, binaryDigits = "101100", number = 0, caoB1
- (a) loop correctly identified as ending here, because number is no longer greater than 0, oeB1
- (a) OUTPUT = 101100, caoB1
- (a) correct verification: 101100 = 32+8+4 = 44, matching the original value of number, oeB1
- (a) Answer: binaryDigits after each pass: 0, 00, 100, 1100, 01100, 101100; OUTPUT = 101100
Question 18
- Level 3 Detailed explanation covering multiple points (hardware simplification, single zero representation, sign bit place value), correct terminology, ideally with an example.5-6
- Level 2 Sound explanation of two or three points with some technical detail.3-4
- Level 1 Basic, limited explanation of one point or an unexplained list.1-2
- Level 0 No relevant content.0
- Indicative content:
- Same addition hardware/process works for positive and negative numbers
- No separate subtraction circuit needed
- Only one representation of zero, unlike sign-magnitude's two
- Sign bit acts as a negative place value
- Supported by a correct example calculation
Mark your answers
Check answers without an account. Some answers can be checked automatically; use the mark scheme to mark the rest.