1/32
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
Depth vs Breadth first traversal: Data types
D : Stack
B : Queue
Depth vs Breadth first traversal: Implementation
D : Usually recursive (or iterative with explicit stack)
B : Usually iterative (with a while loop)
Depth vs Breadth first traversal: Use case
D : Navigating a maze
B : Shortest path on an unweighted graph
Depth vs Breadth first traversal: Required graph state
Connected for both (no orphans)
It is a form of depth-first traversal that must start at the root.
Three properties for a graph to be a tree?
It must:
contain no cycles
be connected
be undirected.
What defines a "Rooted Tree" and a "Binary Tree"?
Rooted Tree: A tree where one vertex is designated as the root, creating parent-child relationships.
Binary Tree: A rooted tree where each node has at most two children.
In-order traversal
1. Infix to RPN (Reverse Polish Notation) conversions;
2. Producing a postfix expression from an expression tree;
3. Emptying a tree.
How is a single stack used to evaluate a RPN expression? (4)
(Starting at LHS of expression) push operands on to stack
Each time operator reached pop top two values off stack
Push result (of applying operator) to stack
When end of expression is reached the top item of the stack is the result
What are the main advantages of using Reverse Polish Notation?
Eliminates the need for brackets in sub-expressions.
Simpler for a computer to evaluate.
Where is Reverse Polish Notation typically used in computer systems?
In interpreters based on a stack (e.g., Postscript and bytecode).
What is the strict prerequisite condition for performing a Binary Search?
The list must be ordered (sorted).
How can the bubble sort be optimised? (2)
Add an early exit flag: Use a boolean flag to track whether any swaps occurred during a pass, and terminate the outer loop early if no swaps were made.
Reduce the inner loop range: Decrease the inner loop’s upper limit by 1 after each pass to avoid re-checking elements that are already sorted.
To what types of graphs can Dijkstra's algorithm be applied in terms of direction and edge weight?
Direction: Can be used with both directed and undirected graphs.
Weight: Can only be used with weighted graphs.
State two typical real-world applications of Dijkstra's algorithm.
Satellite navigation systems (displaying the shortest/fastest route).
Network routers (finding the shortest path when routing packets).
When setting up a table to trace Dijkstra's algorithm, what initial tentative distances are assigned to the start node and all other nodes?
The start node is assigned a tentative distance of 0, and all other unvisited nodes are assigned infinity (∞).