You are on page 1of 2

Bitwise Manipulation Karnaugh Maps Boolean Operators

Shifts • Used to simplify Boolean expressions AND - two conditions must be met
• Shifts on binary numbers are called logical shifts. • Can be used for truth tables with for the statement to be true
• May be a logical shift left or logical shift right. between two and four variables
Written as AND or .
• Move all the bits of the number a specific number • Values in columns and rows must be
of places left or right. written using grey code
• Involves adding a number of zeros at the beginning • Columns and rows only differ by one
or end. bit
• This gives a multiplication for left shifts and division 1) Write the truth table as a Karnaugh
for right shifts by two to the power of the number of Map
places shifted. 2) Highlight all the 1s A B Q
• Moving one place will double or halve the number. 3) Only groups of 1s with edged equal 0 0 0
Masks to a power of 2 may be highlighted
0 1 0
4) Remove variables which change
• Combines binary numbers with a logic gate such as 1 0 0
within the highlighting
AND or XOR.
5) Keep variables which do not change 1 1 1
• May multiply or otherwise change the involved
numbers.
OR - at least one condition must be
met for the statement to be true

Unit 1.4 Data Types, Data Structures and Algorithms


Written as OR or +

Data Structures Data Types Trace Tables


Records Graphs Integer • A method of recording the values used within an algorithm at
• A row in a file or table • Notes connected by edges or arcs. • A whole number each stage of processing to help in troubleshooting
• Tests algorithms for logic errors which occur when the A B Q
• Widely used in databases • Directed graphs allow edges to be • May be positive, negative or 0
• Made up of fields traversed in one direction only. • Cannot have a fraction or algorithm is executed. 0 0 0
Lists • Undirected graphs allow edges to be decimal point • Simulates the steps of algorithm. 0 1 1
• A number of items traversed in both directions. • Often used for counting • Each stage is executed individually allowing inputs, outputs, 1 0 1
• Items can occur more than once • Weighted graphs attach a cost to each objects variables, and processes to be checked for the correct value
1 1 1
• Data can be of more than one data type arc. • e.g. 5, -1, 0, 10 at each stage.
Tuples • Implemented using an adjacency list or Real • A great way to spot errors
adjacency matrix. • Positive or negative number Stage X Y Output NOT – inverts the result, e.g. NOT(A
• An ordered set of values
• Adjacency matrix - easy to add nodes • May have a decimal point AND B) will only be false when both
• Cannot be changed once initialised 1 3 1
and to work with. • Often used for measurements A and B are true
• Initialised with regular rather than square X = 3 2 2
brackets • Adjacency list - space efficient. • e.g. 5, -10, 100.556, 15.2 Written as NOT or ̅
Y = 1 3 2
Arrays Trees Character while X > 0
• Connected graphs with root and child • A single symbol
4 3
• An ordered set of elements, each of the Y = Y + 1
same type. nodes. • May be a letter, number or X = X - 1 5 1
• A 1D array is like a list. • A note is an item in the tree. character print(Y) 6 4
• A 2D array is like a table. • An edge connects two nodes together. • Uppercase and lowercase 7 0
• A 3D array is like a multi page spreadsheet. • A roof is a node with no incoming letters are different characters 8 4 A Q
• 2D arrays are searched first by the rows nodes. • e.g. A, a, 5, M, ^, @ 1 0
and then the columns. • A child is a node with incoming edges. String 0 1
Linked Lists • A parent is a node with outgoing edges. • A collection of characters Normalisation Combining and Manipulating
• Dynamic data structure. • A subtree is a section of a tree • Can store one or many strings • Maximises the precision Boolean Operations
consisting of a parent node with child in any number of bits. • Boolean operators can be
XOR – Also know as Exclusive OR.
• Stores an ordered list. • Often used to contain text
nodes. • Adjust the mantissa so combined to form Boolean Works the same as an OR gate, but
• Contents need not be in contiguous data • Leading 0s are not trimmed so
• A leaf is a node with no child nodes. useful for storing phone that it begins with 01 for equations will output 1 only if one or the other
locations.
• Items are called nodes. • A binary tree is a tree where each node numbers positive numbers and 10 • This follows the same way and not both inputs are 1.
• Each node contains a data field and a link has two or fewer children. Boolean for negative numbers. as combining standard Written as XOR or ⊕
or pointer field. • Binary trees store information in a way • True or False only maths operators
• The data field contains the data itself. which is easy to search. • The equation can be
• The pointer field contains the address of • They often store each node with a left Binary Subtraction represented by a truth table
the next item. and right pointer. • Use Two’s Complement. • Sometimes a long
• Use the same rules as adding expression can share a
Positive Integers in Binary a negative number. Binary Addition truth table with a shorter A B Q
• Each binary digit is called a bit • Use binary addition with a •0 +0=1 expression 0 0 0
• Eight bits form a byte negative two’s complement •0 +1=1 • It is better to use the
0 1 1
• Four bits (half a byte) is called a nybble number. • 1 + 1 = 10 shorter version.
1 0 1
• The most significant bit is furthest left • 1 + 1 + 1 = 11
• The least significant bit is furthest right 1 1 0
Simplifying Boolean Algebra Floating Point Numbers Traversing Data Structures List and Queue Operations Logic Circuits - Adders
De Morgan’s Laws • Similar to scientific Pre-order Traversal List Operations • Adds together the number of TRUE inputs.
notation 1. Root node • isEmpty() Checks if the list is empty • Outputs this number in binary.
• Numbers are split into 2. Left subtree • append(value) Adds a new value to Half Adder
Mantissa and Exponent 3. Right subtree the end of the list • Has two inputs, A and B.
• The mantissa has the In-order Traversal • remove(value) Removes the value • Has two outputs, SUM and CARRY.
binary point after the most 1. Left subtree the first time it occurs
Distribution • Has two logic gates, AND and XOR.
significant bit 2. Root node
• in the list • When A and B are FALSE both outputs are
3. Right subtree
• Then convert the • search(value) Searches for a value FALSE.
Post-order Traversal
exponent to decimal in the list. • When one of A or B is true, SUM is TRUE.
1. Left subtree
• Move the binary point 2. Right subtree • length() Returns the length of the list • When both inputs are TRUE, CARRY is TRUE.
according to the exponent 3. Root node • index(value) Returns the position of A B C S
the item 0 0 0 0
• insert(position, value) Inserts a value
0 1 0 1
at a given position
Association • pop() Returns and removes the last 1 0 0 1
item in the 1 1 1 0
• list
• pop(position) Returns and removes
the item at the given
Commutation • position
Queue Operations
• enQueue(value) Adds a new item to Full Adder
the end of the queue • Like a half adder but with a third input, CARRY
• isEmpty() Checks if the queue if IN.
Double Negation empty • Formed from two XOR gates, two AND gates
• isFull() Checks if the queue is full and an OR gate.
• May be chained together to produce a Ripple
Adder with many inputs.

Unit 1.4 Data Types, Data Structures and Algorithms A B C in C out Sum
0 0 0 0 0
0 0 1 0 1
Character Sets Stacks and Queues Stack and Queue Logic Circuits - D-Type Flip Flops 0 1 0 0 1
• A collection of codes and their corresponding Stacks Operations • Stores the value of one bit.
0 1 1 1 0
characters. • Last in first out Stacks • Has a clock, two inputs and a control signal.
ASCII • Items can only be • isEmpty() - Checks if the • The clock is a regular pulse from the CPU. 1 0 0 0 1
• American standard code for information interchange added or removed stack is empty • The clock is used to coordinate the computer’s components. 1 0 1 1 0
• Older character set from the top • push(value) - Adds a new • A clock pulse has edges which either rise or fall. 1 1 0 1 0
• Uses 7 bits representing 27 (128) characters • Used for back or value to the top of the • The output can only change at a rising edge. 1 1 1 1 1
• Insufficient characters to represent multiple undo buttons stack • Used four NAND gates.
languages • Can be dynamic or • peek() - Returns the top • Updates the value in Q to the value in D whenever the clock
Unicode static structure value of the stack rises.
• Developed in response to ASCIIs limited characters Queues • pop() - Returns and • Q is the stored value
• Varying number of bits allows over 1 million • First in first out removes the top value of
characters data structure the stack
• Many characters yet to be used • Items are added at • size() - Returns the size of
• Includes different symbols and emojis the beginning and the stack
removed at the end • isFull() - Checks if the
Hexadecimal • Used in printers stack is full
• Base 16. and keyboards Queues
• Characters 0-9 are used as usual. • Linear queue with • enQueue(value) - Adds a Additional and Subtraction of Floating Point
• A-F are used instead of 10-15. items added into new item at the end of the Numbers
• Place values begin with 1 and increase in powers of the next space queue Addition
16 • Space inefficient • deQueue() - Removes the • The exponent must be the same
Converting Hexadecimal to Binary • Uses pointers at item at the end of the • Add the mantissas
• Convert each digit to a decimal number the front and back queue • Normalise if needed
• Convert these to a binary nybble • Circular queues • isEmpty() - Checks if the Subtraction
• Join the nybbles into a single binary number have a rear pointer queue if empty • The exponents must be the same
Converting Hexadecimal to Decimal that can loop back • isFull() - Checks if the • Covert to two’s complement then add
• Convert to binary to the beginning to queue is full • Use binary addition on the mantissas
• Convert the binary to decimal use empty space. • Normalise if needed

You might also like