Send a link to your students to track their progress
94 Terms
1
New cards
Name the five primitive data types
Integer, real (floating point), character, string, Boolean
2
New cards
What is casting, and give an example of why it might be needed?
Converting one data type to another, e.g. converting user input (usually a string like "12") into an integer so a numerical comparison like "is this value below 20" can be performed
3
New cards
What is a bit, and what is a byte?
A bit is the smallest unit of digital information, either 0 or 1; a byte is a group of 8 bits
4
New cards
What does each column in an 8-bit binary number represent, from right to left?
Powers of 2: 1, 2, 4, 8, 16, 32, 64, 128 (i.e. 2^0 up to 2^7)
5
New cards
What is the Most Significant Bit (MSB) used for in signed binary numbers?
It indicates whether the number is positive (MSB = 0) or negative (MSB = 1)
6
New cards
How does sign and magnitude representation work?
The MSB represents the sign (1 = negative, 0 = positive), and the remaining bits represent the magnitude (size) of the number as normal binary
7
New cards
What is the method for converting a positive denary number to two's complement?
Convert the absolute value to binary as normal (no change needed since it's positive)
8
New cards
What is the method for converting a negative denary number to two's complement?
Take the binary representation of the positive (absolute) value, invert all the bits (0s become 1s and 1s become 0s), then add 1
9
New cards
Why is two's complement preferred over sign and magnitude for arithmetic?
Calculations (especially addition and subtraction) on two's complement numbers are less computationally intensive/more straightforward than sign and magnitude
10
New cards
What is the consequence of using a sign bit (in either sign & magnitude or two's complement) on the maximum value that can be stored?
The maximum size of the number that can be stored is halved, since one bit is used for the sign rather than the magnitude
11
New cards
What is overflow in binary arithmetic, and when does it occur?
Overflow occurs when the sum of two binary numbers exceeds the number of bits available to store the result, which can incorrectly flip the sign bit and produce an incorrect result
12
New cards
How is binary subtraction typically performed using two's complement?
Convert the number being subtracted into its two's complement (invert the bits and add 1), then add this to the other number using normal binary addition, discarding any overflow bit beyond the given number of bits
13
New cards
What is hexadecimal, and why is it used instead of binary?
A base-16 number system (0-9 then A-F); it's more concise (one hex digit represents 4 binary bits/a nibble), easier for humans to read/write, and less error-prone to communicate than long binary strings
14
New cards
Give two practical uses of hexadecimal
Any two of: debugging, configuring hardware devices, cryptographic algorithms, defining colours (e.g. in web design/CSS)
15
New cards
How do you convert a binary number to hexadecimal?
Split the binary number into groups of 4 bits (nibbles) starting from the right, then convert each nibble to its hexadecimal value
16
New cards
What are the two main components of a floating point binary number?
The mantissa (holds the significant digits/precision of the number) and the exponent (controls how far the binary point is shifted, scaling the number)
17
New cards
What does it mean for a floating point binary number to be normalised?
The mantissa starts with 01 (for positive numbers) or 10 (for negative numbers), immediately after the sign bit — this ensures a consistent, unambiguous format
18
New cards
Why is normalising floating point numbers useful?
It ensures a consistent format for representation and makes arithmetic and comparisons between floating point numbers more straightforward
19
New cards
What must be true before adding or subtracting two floating point numbers?
Both numbers must have the same exponent — this may require shifting the mantissa of one number and adjusting its exponent to match the other first
20
New cards
What happens to a floating point number's exponent if its mantissa needs to be shifted right during normalisation after an arithmetic operation?
The exponent is incremented (increased) to compensate for the mantissa being shifted right
21
New cards
What is a logical shift, and what are the two types?
Moving all the bits in a binary number left or right by a specified number of positions; the two types are left shift and right shift
22
New cards
What is the effect of a single logical left shift on an unsigned binary number's value?
It doubles the value (equivalent to multiplying by 2)
23
New cards
What is the effect of a single logical right shift on an unsigned binary number's value?
It halves the value (equivalent to integer division by 2)
24
New cards
What is a mask in the context of bitwise manipulation?
A binary number used in bitwise operations to isolate, set, clear, or toggle specific bits in another binary value, acting like a filter
25
New cards
How does a bitwise AND operation work with a mask?
The result bit is 1 only if both the corresponding bit in the original number AND the mask are 1; otherwise the result is 0 — used to isolate/clear specific bits
26
New cards
How does a bitwise OR operation work with a mask?
The result bit is 1 if either the corresponding bit in the original number OR the mask is 1; otherwise the result is 0 — used to set specific bits to 1
27
New cards
How does a bitwise XOR operation work with a mask?
The result bit is 1 only if exactly one of the corresponding bits (in the number or the mask) is 1, but not both; used to toggle/flip specific bits
28
New cards
What is a character set, and why is it needed?
A list of all characters and their associated binary code, standardising how binary values map to characters so different systems interpret them consistently
29
New cards
How many bits does standard ASCII use, and how many characters can it represent?
Any two of: limited to 128 characters (mainly English), not suitable for multilingual/non-English text, no provision for modern symbols/emoji
31
New cards
How does Unicode address the limitations of ASCII?
It uses a much larger bit range (up to 32 bits depending on encoding), allowing it to represent a huge variety of characters from different languages, scripts, and symbols including emoji
32
New cards
What is the trade-off between ASCII and Unicode?
ASCII is more storage-efficient (fewer bits per character) but can only represent 128 characters; Unicode can represent far more characters (including international text and emoji) but requires more storage
33
New cards
What is an array, and what are its key characteristics?
An ordered, fixed-size (static) collection of elements that can only store one data type, with elements accessed directly by index
34
New cards
When is an array an appropriate data structure to use?
When you need a fixed-size collection with random access to elements by index, and don't need to frequently resize, insert, or remove elements in the middle
35
New cards
What is a record, and give an example use case
A single entity made up of a group of related fields (potentially of different data types), e.g. a row in a database representing one student's ID, name, and grade
36
New cards
What is the key difference between a list and an array?
A list is dynamic (can change size, elements can be non-contiguous in memory, and can hold multiple data types), whereas an array is fixed-size, contiguous, and holds only one data type
37
New cards
What is a tuple, and how does it differ from a list?
An ordered, immutable set of values of any type — unlike a list, once created its elements cannot be added, removed, or changed
38
New cards
Give the pseudocode operation used to add a new value to the end of a list, and one used to insert at a specific position
append(value) adds to the end; insert(position, value) inserts at a given position
39
New cards
What is a linked list, and how does it differ structurally from an array?
A dynamic data structure holding an ordered sequence, where each item (node) contains a data field and a pointer to the next item; unlike an array, nodes don't need to be stored in contiguous memory locations
40
New cards
How do you traverse a linked list?
Start at the node referenced by the 'start' pointer, output/process the data at the current node, then follow that node's pointer to the next node, repeating until a null/empty pointer signals the end of the list
41
New cards
How is a new node added into the middle of a linked list (without moving existing data)?
The new value is placed in the next free memory location, and the pointer of the preceding node is updated to point to the new node, while the new node's pointer is set to point to what the preceding node used to point to
42
New cards
How is a node "removed" from a linked list?
The pointer of the preceding node is updated to skip over (point past) the node being removed and point directly to the next node instead — the removed node's data isn't erased, it is just no longer part of the traversal path
43
New cards
Give one advantage and one disadvantage of a linked list compared to an array
Advantage: values can be easily added or removed by just updating pointers, without shifting other elements. Disadvantage: uses more memory (extra space for pointers) and items can't be accessed directly by index — you must traverse from the start
44
New cards
What does LIFO stand for, and which data structure uses it?
Last In First Out — used by a stack
45
New cards
Name the main operations of a stack
push(value) — add to top; pop() — remove and return top value; peek() — return top value without removing; isEmpty(); size()
46
New cards
Give a real-world use of a stack in computing
Reversing an action such as "undo" or navigating "back" a page in a browser
47
New cards
What does FIFO stand for, and which data structure uses it?
First In First Out — used by a queue
48
New cards
Name the main operations of a queue
enQueue(value) — add to the back; deQueue() — remove and return from the front; peek(); isEmpty(); isFull()
49
New cards
What is the difference between a linear queue and a circular queue?
A linear queue is implemented as a simple array where items are added/removed from fixed ends, which can waste space once the rear reaches the end of the array; a circular queue reuses freed space at the front by wrapping the rear pointer back to the start of the array once it reaches the end
50
New cards
What is a graph, made up of?
A set of vertices/nodes connected by edges (also called arcs or pointers)
51
New cards
What is the difference between a directed and an undirected graph?
In a directed graph, edges can only be traversed in one direction; in an undirected graph, edges can be traversed in both directions
52
New cards
What is a weighted graph?
A graph where a numerical value (weight) is attached to each edge
53
New cards
What is an adjacency matrix used for?
Representing a graph as a grid of rows and columns, where a value in the matrix indicates whether (and, for weighted graphs, how strongly) two nodes are connected by an edge
54
New cards
How does a breadth-first search traverse a graph?
It systematically visits all neighbours of the current node before moving on to their neighbours (visiting layer by layer), using a queue to keep track of nodes to visit next
55
New cards
How does a depth-first search traverse a graph?
It explores as far as possible along one branch before backtracking, using a stack to keep track of nodes to visit next
56
New cards
*What data structure does breadth-first search use, and what data structure does depth-first search use?
Breadth-first search uses a queue; depth-first search uses a stack
57
New cards
What is a tree, and how does it relate to a graph?
A connected, undirected graph with nodes and pointers that has a hierarchical structure with a single root node and no cycles
58
New cards
Define the following tree terms: root, leaf, parent, child
Root: the single top node with no incoming edges. Leaf: a node with no children. Parent: a node with outgoing edges to another node. Child: a node with an incoming edge from another (parent) node
59
New cards
What is a binary tree?
A rooted tree where every node has a maximum of two children
60
New cards
What is the order of traversal for post-order (depth-first) traversal of a binary tree?
Left subtree, then right subtree, then the root node
61
New cards
What is the order of traversal for breadth-first traversal of a binary tree?
Start at the root, then visit each node level by level, moving left to right across each level before moving down to the next
62
New cards
How do you decide where to insert a new value into a binary search tree?
Compare the new value to the current node: if smaller, move to the left child; if larger, move to the right child; repeat until reaching an empty position, where the new value is inserted
63
New cards
How do you delete a leaf node (no children) from a binary search tree?
Simply remove it directly, since it has no children to reconnect
64
New cards
How do you delete a node with one child from a binary search tree?
Replace the node being deleted with its single child
65
New cards
How do you delete a node with two children from a binary search tree?
Replace the node with its in-order successor (the minimum value in its right subtree, or alternatively the maximum value in its left subtree), then delete that successor node from its original position
66
New cards
What is a hash table, and what is it used for?
An associative array combined with a hash function that maps keys to indexes, providing fast (potentially constant-time) access to data for searching and indexing
67
New cards
What is a collision in a hash table?
When the hash function produces the same hash value (index) for two or more different keys
68
New cards
What is linear probing, as a method of resolving hash table collisions?
When a collision occurs, the data is placed in the next available (empty) position in the table, checked sequentially or at a set interval, until a free slot is found
69
New cards
What is chaining, as a method of resolving hash table collisions?
Instead of storing data directly in the table, each hash table slot points to a linked list; when a collision occurs, the new item is added to that slot's linked list (chain) rather than overwriting existing data
70
New cards
*What is a drawback of using linear probing to resolve collisions?
It reduces the efficiency of retrieval, since if a collision occurred during insertion, the retrieval process may need to check multiple locations sequentially before finding (or confirming the absence of) the correct data
71
New cards
What is rehashing, and why is it used?
Creating a new (usually larger) hash table and re-inserting all existing items using the hash function again; it's used when a table becomes too full or has too many collisions, which would otherwise degrade performance
72
New cards
What is the order of precedence for Boolean operators (highest to lowest)?
Brackets first, then NOT, then AND, then OR
73
New cards
What does the AND (conjunction) operator return, and when?
Returns TRUE only if both inputs are TRUE; otherwise returns FALSE
74
New cards
What does the OR (disjunction) operator return, and when?
Returns TRUE if either input is TRUE; only returns FALSE if both inputs are FALSE
75
New cards
What does the NOT (negation) operator do?
Inverts the input value — NOT TRUE = FALSE, and NOT FALSE = TRUE
76
New cards
What does the XOR (exclusive disjunction) operator return, and when?
Returns TRUE if the inputs are different from each other; returns FALSE if the inputs are the same
77
New cards
What is a truth table used for?
Visualising all possible input combinations for a Boolean expression and the resulting output for each combination
78
New cards
What is a Karnaugh map used for?
A visual tool for simplifying Boolean algebra expressions by grouping together terms with common factors, making it easier to identify and eliminate redundant terms
79
New cards
What are the rules for forming valid groups on a Karnaugh map?
Groups must be rectangular, must contain a number of 1s that is a power of 2 (1, 2, 4, or 8), should be made as large as possible, can overlap, and the grid wraps around at the edges
80
New cards
Give the general AND rule for X AND 1, and for X AND 0
X AND 1 = X; X AND 0 = 0
81
New cards
Give the general OR rule for X OR 1, and for X OR 0
X OR 1 = 1; X OR 0 = X
82
New cards
What is De Morgan's Law for NOT(A AND B)?
NOT(A AND B) is equivalent to (NOT A) OR (NOT B) — negate each variable and flip AND to OR
83
New cards
What is De Morgan's Law for NOT(A OR B)?
NOT(A OR B) is equivalent to (NOT A) AND (NOT B) — negate each variable and flip OR to AND
84
New cards
What is the distributive law in Boolean algebra?
A AND (B OR C) is equivalent to (A AND B) OR (A AND C); similarly A OR (B AND C) is equivalent to (A OR B) AND (A OR C) — similar to factorising in normal maths
85
New cards
What is the associative law in Boolean algebra?
(A AND B) AND C is equivalent to A AND (B AND C), and the same applies for OR — brackets can be removed and variables regrouped without changing the result
86
New cards
What is the commutative law in Boolean algebra?
The order of variables does not change the result: A AND B is the same as B AND A, and A OR B is the same as B OR A
87
New cards
What is the double negation law in Boolean algebra?
NOT(NOT(A)) = A — negating a variable twice returns the original variable
88
New cards
What is a D-type flip flop, and what does it store?
A fundamental digital circuit component (a type of bistable circuit) used to store the state of 1 bit of data, changing state only on the edge of a clock pulse
89
New cards
What happens to the outputs Q and NOT(Q) of a D-type flip flop on the rising edge of the clock pulse?
If the data input D is high (1), Q goes high and NOT(Q) goes low; if D is low (0), Q goes low and NOT(Q) goes high — and Q holds this value until the next rising clock edge
90
New cards
What are the inputs and outputs of a half adder circuit?
Two inputs, A and B; two outputs, Sum (S) and Carry out (Cout)
91
New cards
How are the Sum and Carry outputs of a half adder calculated in terms of logic gates?
Sum = A XOR B; Carry out = A AND B
92
New cards
What are the inputs and outputs of a full adder circuit?
Three inputs: A, B, and a carry in (Cin); two outputs: Sum (S) and Carry out (Cout)
93
New cards
How can a full adder be built using half adders?
Using two half adders (the first combining A and B, the second combining that result's sum with Cin) plus an OR gate to combine the two carry outputs into the final Cout
94
New cards
*How could four full adder circuits be used together to add two 4-bit binary numbers?
By chaining four full adders together, with the carry-out of each adder connected to the carry-in of the next adder along, allowing the carry to propagate correctly across all 4 bits