Topic 3: Fundamentals of Algorithms Flashcards
1
Q
What are the two types of graph traversal?
A
Breadth first
Depth first
2
Q
What is the pseudocode to carry out a depth first traversal?
A
SUB dfs(graph, currentVertex, visited)
append currentVertex to list of visited nodes
FOR vertex in graph[currentVertex]
IF vertex NOT IN visited then
dfs(graph, vertex, visited)
ENDIF
ENDFOR
END SUB
3
Q
What ADT does a depth first traversal use?
A
Stack
4
Q
What ADT does a breadth first traversal use?
A
Queue
5
Q
A