Graph Theory Flashcards

1
Q

What is a tree?

A

An undirected graph with no cycles

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

What is a rooted tree?

A

Tree with a designated root node where every edge either points away from or towards the root node

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

what is an adjacency list?

A

a way to represent a graph as a map from nodes to lists of edges

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

write generic dis for a graph

A
function dis(at):
if visited[at]: return true
visited[at] = true

neighbors = graph[at]
for next in neighbors: dfs(next)

# Start DFS at node zero
start_node = 0
dfs(start_node)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly