9.2 (Graph Representations) Flashcards

1
Q

Which graph operation inserts a new vertex into the graph?

A

Add Vertex

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

Which graph operation creates a connection between two vertices?

A

Add Edge

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

Which graph operation deletes a vertex and all its edges?

A

Remove Vertex

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

Which graph operation deletes a specific edge between two vertices?

A

Remove Edge

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

Which graph operation determines if there is an edge between two vertices?

A

Edge Exists

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

Which graph operation retrieves all adjacent vertices of a given vertex?

A

Get Neighbors

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

Which graph operation counts the number of edges connected to a vertex?

A

Get Degree

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

Which graph operation determines if all vertices are reachable?

A

Graph is Connected

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

What are the two common graph representations?

A

1) Adjacency Matrix Representation
2) Adjacency List Representation

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

Which representation is best for constant-time edge lookup and has dense graphs?

A

Adjacency Matrix Representation

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

Which representation is best for more sparse graphs and has fast traversal?

A

Adjacency List Representation

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

If a graph has V vertices, the number of edges E ranges between [ ______, ________]

A

[0, V/(V-1) / 2]

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

What is the adjacency matrix for hasEdge and addEdge?

A

O(1)

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

What is the adjacency matrix for Space?

A

O(v^2)

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

What is the adjacency matrix for getNeighbors?

A

O(v)

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

What is the adjacency list for addEdge and getNeighbors?

17
Q

What is the adjacency list for space?

18
Q

What is the adjacency list for hasEdge?

A

O(min(v, e))

19
Q

Why is adjacency list representattino preferable?

A

it requires less space