Revision Library

Data Types, Data Structures and Boolean Algebra - Worksheets, Questions and Revision

14 original exam-style questions - 8 pages of questions with a full mark scheme - free printable PDF.

Download PDFJump to mark scheme (page 9)Read the revision guide
« Previous: Exchanging Data: Databases, Networks and Web TechnologiesNext: Legal, Moral, Cultural and Ethical Issues »
Revision Library
revisionlibrary.co.uk
A-Level · Computer Systems (Component 1)

A1.4 Data Types, Data Structures and Boolean Algebra

OCR H446 · Calculators not allowed · about 185 minutes
Total Marks
Name: _______________________________    Date: ____ / ____ / ______
Answer ALL questions. Show all your working.
1
This question is about primitive data types and number base conversions.
(a)State the most appropriate primitive data type for each of the following items of data: (i) a customer's age in whole years (ii) the price of an item in pounds and pence (iii) whether a user is currently logged in (iv) the initial letter of a person's surname.(4)
(b)Convert the denary integer 214 into an 8-bit unsigned binary number. Show your working.(2)
(c)Convert your answer to part (b) into hexadecimal.(2)
(d)Convert the hexadecimal value 2F into an 8-bit binary number, and state its denary value.(2)
(Total for Question 1 is 10 marks)
2
This question is about two's complement representation and binary addition.
(a)Represent the denary number -45 as an 8-bit two's complement binary number. Show your working.(2)
(b)Represent the denary number 77 as an 8-bit two's complement binary number.(1)
(c)Add your answers to parts (a) and (b) together in binary, showing your working, and state the resulting bit pattern.(3)
(d)A programmer adds the 8-bit two's complement numbers 01111111 and 00000001. State the resulting bit pattern, and explain why this result demonstrates arithmetic overflow.(2)
(Total for Question 2 is 8 marks)
3
This question is about floating point representation.
(a)A computer represents floating point numbers using an 8-bit mantissa and a 4-bit exponent, both stored in two's complement, with the mantissa normalised so that its first two bits differ. Represent the denary integer 22 in this floating point form, showing your working for both the mantissa and the exponent.(3)
(b)State what is meant by a normalised mantissa, and explain why floating point numbers are stored in normalised form.(2)
(c)Many decimal fractions, such as 0.1, cannot be represented exactly in binary floating point. Explain why this happens, and the effect it can have on a program that repeatedly adds 0.1 to a running total.(2)
(d)State the effect on the floating point number system of allocating (i) more bits to the exponent and (ii) more bits to the mantissa, keeping the total number of bits used unchanged.(2)
(Total for Question 3 is 9 marks)
4
This question is about character encoding.
(a)State the name of the character encoding standard that can represent characters and symbols from all the world's writing systems, in contrast to standard ASCII, which only covers a limited character set.(1)
(b)Given that the ASCII code for the character 'A' is 65, state the ASCII code for the character 'H'.(1)
(c)A company's customer database must store names containing accented and non-Latin characters (for example, an umlaut in Muller, or a Chinese name). Explain one advantage of storing this data using Unicode rather than ASCII.(2)
(d)A new messaging app must support 200 different characters using a fixed-length binary code. Calculate the minimum number of bits required per character, showing your working.(2)
(Total for Question 4 is 6 marks)
5
A program uses the following pseudocode to process a set of 5 test scores stored in an array:
DECLARE scores : ARRAY[0:4] OF INTEGER
scores[0] <- 12
scores[1] <- 45
scores[2] <- 8
scores[3] <- 45
scores[4] <- 19
total <- 0
FOR i <- 0 TO 4
    total <- total + scores[i]
NEXT i
average <- total / 5
OUTPUT average

Use this pseudocode to answer parts (a) to (d).
(a)State the name of the data structure declared by the line 'DECLARE scores : ARRAY[0:4] OF INTEGER', and state the data type of each element it stores.(1)
(b)Complete a trace table for the FOR loop, showing the values of i, scores[i] and total for each of the 5 iterations.(5)
(c)State the value that will be output by the program.(1)
(d)Rewrite the line 'average <- total / 5' so that integer (whole-number) division is used instead of real division, and state the new value that would be output.(2)
(Total for Question 5 is 9 marks)
6
A program uses the following pseudocode:

TYPE StudentRecord
    DECLARE studentID : INTEGER
    DECLARE name : STRING
    DECLARE grade : CHAR
ENDTYPE
DECLARE student1 : StudentRecord
student1.studentID <- 10234
student1.name <- "Amara Okafor"
student1.grade <- 'B'
(a)State the term used to describe a data structure, such as StudentRecord above, that groups together related data items, which may be of different data types, under a single identifier.(1)
(b)State the value stored in student1.name after the code above has executed.(1)
(c)Write pseudocode to (i) declare an array called cohort of 30 StudentRecord elements, and (ii) set the grade field of the 5th student in the array to 'A'.(3)
(d)Explain one advantage of using a single array of StudentRecord elements, rather than three separate arrays (one for IDs, one for names and one for grades), to store the same cohort data.(2)
(Total for Question 6 is 7 marks)
7
A program implements a stack using the following pseudocode:
DECLARE stack : ARRAY[0:9] OF INTEGER
DECLARE top : INTEGER
top <- -1

PROCEDURE Push(value : INTEGER)
    top <- top + 1
    stack[top] <- value
ENDPROCEDURE

FUNCTION Pop() RETURNS INTEGER
    DECLARE value : INTEGER
    value <- stack[top]
    top <- top - 1
    RETURN value
ENDFUNCTION
(a)State the name of the abstract data type shown above, and state its access principle (the order in which items are added and removed).(2)
(b)The following sequence of calls is made on an initially empty stack: Push(6), Push(2), Push(9), Pop(), Push(4), Pop(), Pop(). Complete a trace table showing the value of top and the contents of the stack array after each call, and the value returned by each Pop().(6)
(c)State the value returned by the final Pop() call in the sequence.(1)
(d)A text editor uses a stack to implement its 'undo' feature, where the most recently made change is the first to be undone. Explain why a stack, rather than a queue, is the appropriate data structure for this purpose.(2)
(Total for Question 7 is 11 marks)
8
A circular queue is implemented as an array of 5 elements (indices 0 to 4), using two pointers: rear points to the next free slot for insertion, and front points to the next item to be removed. Both pointers start at index 0.

Enqueue(value): queue[rear] <- value, then rear <- (rear+1) MOD 5
Dequeue(): value <- queue[front], then front <- (front+1) MOD 5, RETURN value
(a)Explain why a linear queue implemented using a fixed-size array can appear to be 'full', and reject further enqueue operations, even when it currently holds far fewer items than the array's capacity.(2)
(b)Explain how implementing the queue as a circular queue overcomes this problem.(2)
(c)The following operations are carried out in order on the circular queue described above: Enqueue(15), Enqueue(23), Enqueue(8), Dequeue(), Enqueue(41), Enqueue(6), Dequeue(). Complete a trace showing the value of front and rear after each operation, and the value returned by each Dequeue().(5)
(d)State the final values of front and rear, and list the values currently stored in the queue in order from front to rear.(2)
(Total for Question 8 is 11 marks)
9
The values 50, 30, 70, 20, 40, 60, 80, 35 are inserted, in that order, into an initially empty binary search tree (BST), where for each node, values less than the node are inserted into its left subtree and values greater than or equal to the node are inserted into its right subtree.
(a)State the value stored at the root of the tree once all eight values have been inserted.(1)
(b)State the left child and the right child of the node containing 30.(2)
(c)State the left child and the right child of the node containing 70.(2)
(d)A pre-order traversal visits nodes in the order: root, then left subtree, then right subtree. State the sequence of values produced by a pre-order traversal of the completed tree.(3)
(e)An in-order traversal visits nodes in the order: left subtree, root, right subtree. State the sequence of values produced by an in-order traversal of the tree, and explain why an in-order traversal of any binary search tree always produces the stored values in ascending order.(4)
(f)State one advantage of storing this data in a binary search tree, rather than in a sorted (ordered) one-dimensional array, in terms of the efficiency of inserting new data values.(2)
(Total for Question 9 is 14 marks)
10
A programmer is implementing a hash table.
(a)Explain what is meant by a hash table, and describe the role played by a hash function when storing and retrieving data in one.(3)
(b)A hash table has 7 slots, indexed 0 to 6, and uses the hash function h(key) = key MOD 7. State the index that each of the following keys initially hashes to: 15, 22, 9, 30, 16. Identify which of these keys collide with an earlier key (hash to a slot already used by a key inserted before it), assuming they are inserted in the order given.(3)
(c)Collisions are resolved using linear probing: if a key's home slot is already occupied, the next slot is checked (wrapping from slot 6 back to slot 0), and so on, until an empty slot is found. Using this method, insert the five keys from part (b), in the order given, into the hash table. State the final contents of all 7 slots.(4)
(d)Explain one disadvantage of using linear probing to resolve collisions when a hash table becomes heavily loaded (close to full).(2)
(Total for Question 10 is 12 marks)
11
Q = (A AND B) OR (NOT C) is a Boolean expression with three inputs, A, B and C.
(a)Complete a truth table for Q, showing the output for all 8 possible combinations of A, B and C (using the standard ordering 000 to 111).(4)
(b)State the number of rows required in a truth table for a Boolean expression with n input variables, and explain why this formula applies.(2)
(c)Describe a logic circuit that implements Q = (A AND B) OR (NOT C), stating the logic gates required and how they are connected.(2)
(d)A different logic gate has the property that its single output is 1 only when its two inputs, A and B, have different values. Identify this logic gate.(1)
(Total for Question 11 is 9 marks)
12
This question is about the laws of Boolean algebra.
(a)State De Morgan's first law, expressing NOT(A AND B) in terms of NOT A, NOT B and OR.(1)
(b)State De Morgan's second law, expressing NOT(A OR B) in terms of NOT A, NOT B and AND.(1)
(c)Simplify the Boolean expression Q = NOT(NOT A OR NOT B) OR (A AND B), showing each step of your working and naming the law used at each step.(4)
(d)Simplify the Boolean expression Q = (A AND B) OR (A AND NOT B), showing each step of your working and naming the law used at each step.(3)
(e)A student claims that (A OR B) AND (A OR C) is equivalent to A OR (B AND C). State whether the student is correct, and name the Boolean law that justifies your answer.(2)
(Total for Question 12 is 11 marks)
13
A security system triggers an alarm (ALARM) if the front door sensor (D) is open AND the system is armed (S), OR if the motion sensor (M) is triggered while the system is armed (S), regardless of the door.
(a)Write a Boolean expression for ALARM in terms of D, S and M.(2)
(b)Using the distributive law, simplify your expression from part (a) so that it uses only one AND gate involving S.(2)
(c)Describe the simplified logic circuit needed to implement ALARM = S AND (D OR M), stating the gates required and their inputs.(2)
(d)Complete a truth table for ALARM = S AND (D OR M), showing the output for all 8 combinations of S, D and M (using the standard ordering 000 to 111).(4)
(e)State the number of rows in the truth table where ALARM = 1, and explain what this means for the behaviour of the security system.(2)
(Total for Question 13 is 12 marks)
14
Priya, a software engineer, is designing two separate programs: (1) a program to manage a print queue for a school's network printer, where print jobs must be handled in the order they are submitted, and (2) a program to store and quickly search a large, frequently-changing dictionary of 50000 words for a spell-checker.

Discuss which data structure(s) would be most appropriate for (1) the print queue and (2) the spell-checker's word list, justifying your choice by comparing at least two suitable data structures for each scenario in terms of how their operations are performed and how efficient they are.
(Total for Question 14 is 9 marks)
Mark scheme · A1.4 Data Types, Data Structures and Boolean Algebra

Question 1

Question 2

Question 3

Question 4

Question 5

Question 6

Question 7

Question 8

Question 9

Question 10

Question 11

Question 12

Question 13

Question 14

Mark your answers

This checks your answers in your browser, stores nothing on a server and needs no account.

Question 1

10 marks
Did your answer earn the marks?

Question 2

8 marks
Did your answer earn the marks?

Question 3

9 marks
Did your answer earn the marks?

Question 4

6 marks
Did your answer earn the marks?

Question 5

9 marks
Did your answer earn the marks?

Question 6

7 marks
Did your answer earn the marks?

Question 7

11 marks
Did your answer earn the marks?

Question 8

11 marks
Did your answer earn the marks?

Question 9

14 marks
Did your answer earn the marks?

Question 10

12 marks
Did your answer earn the marks?

Question 11

9 marks
Did your answer earn the marks?

Question 12

11 marks
Did your answer earn the marks?

Question 13

12 marks
Did your answer earn the marks?

Question 14

9 marks
Did your answer earn the marks?
Mark my answers