Topic 3: Fundamentals of Algorithms Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What are the two types of graph traversal?

A

Breadth first
Depth first

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What ADT does a depth first traversal use?

A

Stack

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What ADT does a breadth first traversal use?

A

Queue

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly