OCR A-Level Computer Science Spec Notes - 1.4 Summarized
OCR A-Level Computer Science Spec Notes - 1.4 Summarized
1 1 0 0 1 0 0 0
● Firstly we know 128 goes into denary so put a 1 under 128 in the table
● Then do 200-128 = 72. Now 64 goes into 72 once so put a 1 in that
● Now do 72-64 = 8. 32 & 16 don't go into 8 but 8 does do put a 1 in there
● Fill the rest of the boxes with 0
● Finito (Answer: 11001000)
● To summarize, keep subtracting and seeing whether the numbers in the top row
go into the subtracted value. It’s hard to explain just practice lmao.
(c) Sign and magnitude & two's complement for negative numbers
Sign & Magnitude:
- In denary, store a sign bit, a ‘+’ or ‘–’ as part of the number
- Simply use the most left-handed bit, to store these as a binary value, 0 for + and 1 for –
0 (+) 1 1 1 1 1 1 1
= 127
Sign Bit 64 32 16 8 4 2 1
1 (-) 1 1 1 1 1 1 1
=-127
Two's Complement: An easy method for subtraction (Overpowered if use correctly):
1. Convert subtraction number into binary
2. Start from most right and keep all values the same until you reach the first ‘1’. Then after
that switch ‘1’s with ‘0’s and ‘0’s for ‘1’s’
3. Add the binary numbers and discard the overflow
0 1 0 1 1 0 1 0
- Just add the numbers which have a 1 below them (64+16+8+2 = 90)
Binary -> Hexadecimal (E.g Convert 0101 1010 to Hexadecimal)
- Split byte into 2 nibbles (0101 1010)
- Convert each nibble separately into Hexadecimal (0101 = 5 / 1010 = 10 = A)
- Combine the result together: 5D
Denary -> Hexadecimal
- Convert Denary into Binary
- Follow instructions for: Binary -> Hexadecimal
Hexadecimal -> Binary
- Split each Hex letter/number up
- Convert each letter/number into binary equivalent
- Join binary up again
Hexadecimal -> Denary
- Follow instructions for: Hexadecimal-> Binary
- Convert Binary into Denary
Alternate Way
- multiply each corresponding Hex digit with increasing powers of 16
3B = 3×161+11×160 = 48+11 = 5910
(g) Representation and normalisation of floating point numbers (Mantissa is normally 5 bits &
exponent is 3. Question will tell you if it changes)
Floating Point Numbers: A way of storing decimals in Binary
1. If a number is positive/negative, look at the first binary digit: 0 =positive, 1 = negative
2. Split into mantissa and exponent.
3. Use the exponent to float the binary point back into place (put decimal point after first
number)
4. Convert to denary.
Negative Values:
1. Split into mantissa and exponent.
2. Evaluate the exponent
3. Move the binary point one place to the left (If exponent is -1 for example)
The number of bits chosen for the mantissa & exponent affects the range and the accuracy of
the values that can be stored:
- If more bits are used for the mantissa = more accurate values.
- But the range is limited by the small exponent.
- If more bits are used for the exponent, = range of values stored is greater.
- But the accuracy is limited by the smaller mantissa.
(b) Linked lists, graphs, stack, queue, tree, binary search tree, hash table
Linked Lists
- Dynamic data structure
- Uses index values/pointers to sort lists in specific ways
- Can be organised into more than one category
- Needs to be traversed until desired element is found
- To add data: data added to the next available space & pointers adjusted
- To remove data: Pointer from previous item set to item that will be removed which
bypasses the removed item
- The contents may not be stored contiguously in memory.
Graphs
- Set of vertices/nodes connected by edges/arcs
- Can be represented by an adjacency matrix
- Edges can be:
● directional or bi-directional
● directed or undirected
● weighted or unweighted
- Searched by breadth/depth first traversal
Stack
- LIFO (Last In First Out)
- 2 pointers (Top/bottom) Top Pointer = Stack Pointer
- Data is added (PUSH) and removed (POP) from the top of the stack
- Stack overflow: When data is trying to go into stack but stack is full
Queue
- FIFO (First In First Out)
- 2 pointers (Start/End) Start Pointer = Queue Pointer
- Data is added (enqueue) from end & data removed (dequeue) from the top of queue
Tree
- Are dynamic branching data structures.
- They consist of nodes that have sub nodes (children).
- The first node at the start of the tree (root node)
- The lines that join the nodes are called (branches)
Binary search tree
- Each node has a maximum of 2 children from a left branch and a right branch.
- To add data to the tree, it is placed at the end of the list in the first available space and
added to the tree following the rules:
● If a child node is less than a parent node, it goes to the left of the parent.
● If a child node is greater than a parent node, it goes to the right of the parent.
Hash table
- Enable access to data that is not stored in a structured manner.
- Hash functions generate an address in a table for the data that can be recalculated to
locate that data.
Symbol (AND):
- ≡ e.g. (A ∧ B) ≡ ¬(¬A V ¬B) ------> (A AND B ≡ NOT (NOT A OR NOT B))
Boolean algebra
There are rules, similar to arithmetic (Statistics if you take A-level Maths), for manipulating
Boolean expressions:
Boolean Rule Boolean Expression Description
OR OR
● AVA≡A ● A OR A ≡ A
● AV0≡A ● A OR 0 ≡ A
● AV1≡1 ● A OR 1 ≡ 1
● A V ¬A ≡ 1 ● A AND NOT A ≡ 1
Absorption ● A V (A ∧ B) ≡ A ● A OR (A AND B) ≡ A
● A ∧ (A V B) ≡ A ● A AND (A OR B) ≡ A
(d) Logic gate diagrams and truth tables
Logic Gates: Building block of a digital circuit used to implement Boolean functions
Truth Table: Mathematical table used with logic gates to list out all possible scenarios of the
corresponding logic gate(s)
OR AVB
NOT ¬A
NAND ¬(A ∧ B)
A B ¬(A ∧ B)
F F T
F T T
T F T
T T F
NOR ¬(A V B)
A B ¬(A V B)
F F T
F T F
T F F
T T F
XOR A⊻B
Full adders
- Combination of half adders to make a full adder
- The sum (S) is an XOR gate
- The carry (C) is an AND gate
- A B and Cin are added together = The result is given in the sum (S) N And a carry bit in
Cout
Series of full adders combined together allows computers to add binary numbers.