What is an algorithm?
A set of instructions which completes a task in a finite time and always terminates
What is graph traversal?
The process of visiting each vertex in a graph
Name the two types of graph traversal
Depth-first search and breadth-first search
Which traversal is best for navigating a maze?
Depth-first search
What is breadth-first traversal useful for?
Shortest path on an unweighted graph
What abstract data type is used for a breadth-first traversal?
Queue
What abstract data type is used in a depth-first traversal?
Stack
What type of graphs can be traversed?
Connected graphs
Can a tree undergo depth-first traversal?
Yes- although it might be more appropriate to use a tree-traversal
Can a graph traversal start from any node?
Yes
What is tree-traversal?
The process of visiting updating or outputting each node in a tree- it is an algorithm
Name the three types of tree-traversal
Preorder- inorder and postorder
Name a use of postorder traversal
Emptying a tree, Infix to RPN (reverse polish notation) conversions, Producing a postfix expression from an expression tree
Which traversal would be used for copying a tree?
Preorder traversal
Name a use of inorder traversal
Outputting the contents of a binary search tree in ascending order
Can inorder traversal be performed on any tree?
No- only binary trees (including binary search trees)
Can preorder traversal be performed on any tree?
Yes
Can postorder traversal be performed on any tree?
Yes
Where does tree traversal start?
At the root
How do traversals work their way around the tree?
Anticlockwise
How would In-Order traversal work
Left, Root, Right. Start from furthest left and go to right
How would Post-Order traversal work
Left, Right, Root. Start from furthest left and check each leaf node, go up the last one until one before root, switch to other leaf node on other side and repeat.
How would Pre-Order traversal work
Root, Left sub-tree, Right sub-tree. Start from top and work down each sub-node
What is the benefit of reverse Polish notation?
It eliminates the need for brackets