1.4 Data Types Data Structures and Algorithms.280155520
1.4 Data Types Data Structures and Algorithms.280155520
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 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