4.3.1 Graph Traversal Flashcards
What is an algorithm?
A set of instructions which completes a task within a finite time and terminates upon completion.
What is Graph Traversal?
The process of visiting each vertex in a graph.
Name 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 search useful for?
Shortest path on an unweighted graph
What ADT is used for a breadth-first traversal?
Queue
What ADT is used for a depth-first search?
Stack
What type of graphs can be traversed?
Connected graphs
Can a tree undergo depth-first traversal?
- Yes
- But it might be more appropriate to use a tree traversal in such a situation
Can a graph traversal start from any node?
- Yes
- Since it is stored in a way that allows to see which nodes have a vertex between them
In what order would this graph be traversed in a breadth-first search? Start from node A.
- A → B,C
- B → C,D
- C → A,B
- D → B,E
A→B→C→D→E
In what order would this graph be traversed in a depth-first search? Start from node A.
- A → B,C
- B → C,D
- C → A,B
- D → B,E
A → B → D → E → C
Goes through one pathway completely before exploring the other.