1.4 Data types, data structures and algorithms Flashcards
1
Q
What is a D-Type Flip Flop and how does it work? (1.4.3)
A
- Logic circuit, stores 1 bit only
- 2 inputs, control signal + clock
- Clock: regular CPU pulse, coordinates, rises / falls
- 4 NAND gates used
2
Q
How does a Half Adder work? (1.4.3)
A
- Takes 2 inputs
- Gives 2 outputs: sum & carry
- Formed of AND & XOR
- When both A & B False, outputs False
- When A or B True, sum True
- When both inputs True, carry True, sum False
3
Q
What is the order for in-order traversal? (1.4.2)
A
- Leftwards:
- Left subtree
- Parent
- Right subtree
- Root
- Rightwards:
- Left subtree
- Parent
- Right subtree
4
Q
What are the 3 types of graph data structures? (1.4.2)
A
- Directed: only traversed in 1 direction
- Undirected: traversed both directions
- Weighted: arcs have cost attached
5
Q
What is the order for pre-order traversal? (1.4.2)
A
- Root node
- Leftwards:
- Left subtree
- Right subtree
- Rightwards:
- Left subtree
- Right subtree
6
Q
How does a Full Adder work? (1.4.3)
A
- Like Half Adder, additional input
- Allows carry representation
- Formed from 2 XOR gates, 2 AND gates, 1 OR gate
- Chained together
7
Q
What are hash tables as data structures? (1.4.2)
A
- Array coupled with hash function
- Hash function takes data, produces unique output
- Maps data to unique index
- If same output, collision, placed in next available
8
Q
How do linked lists work? (1.4.2)
A
- Dynamic, holds ordered sequence
- Each item called node, contains data, & pointer (next item in list)
9
Q
What are stacks and queues used for? (1.4.2)
A
Stacks:
- Performing depth-first searches on graphs
- Tracking user inputs (e.g. undo)
- Backtracking (e.g. pathfinding)
Queues:
- Performing breadth-first searches on graphs
- Transferring data between processors
- Process scheduling
10
Q
What is a root, child, and leaf, in tree data structures? (1.4.2)
A
Root: node with no incoming nodes
Child: node with incoming edges
Parent: node with outgoing edges
Leaf: node with no children
11
Q
What is the order for post-order traversal? (1.4.2)
A
- Leftwards:
- Left subtree, leaf first
- Right subtree, leaf first
- Parent
- Rightwards:
- Left subtree, leaf first
- Right subtree, leaf first
- Parent
- Root