Fundamentals of Algorithms Flashcards
What is Graph Traversal
Graph Traversal is the process of visiting each vertex in a graph.
What is an algorithm
A set of instructions which completes a task in a finite time and always terminates
Name the two types of graph traversal
Depth-first search and breadth-first search
Which type of graph traversal is best for 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 requirement must a graph have to be searched
it must be connected.
What is tree traversal
The process of visiting/updating/outputting each node in a tree
Name the three types of tree traversal
Preorder, inorder and postorder
Name a use of postorder tree traversal
Infinix to RPM
Producing a postfix expression from an expression tree
Name a use of inorder tree traversal
Outputting the contents of a binary search tree in ascending order
Can an inorder traversal be performed on any tree
no, it must be a binary tree, however postorder and preorder can be performed on any tree
How do tree traversals work their way around the tree?
anticlockwise
Why is reverse polish notation used
RPN eliminates the need for brackets, aswell as being easier to work with in computers.