SW17: Graph Representations Flashcards

(20 cards)

1
Q

True or False: Adjacency lists are implemented using an array of pointers to linked lists.

A

TRUE

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

What is the time complexity to check if an edge (u, v) exists in an Adjacency Matrix?
A. O(n)
B. O(log n)
C. O(1)
D. O(n²)

A

C. O(1)

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

True or False: An adjacency matrix for an undirected graph is always symmetric along the main diagonal.

A

TRUE

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

In an Adjacency List, the space complexity is proportional to:
A. n²
B. n + m
C. m²
D. n − m

A

B. n + m

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

Given the following Adjacency Matrix for a directed graph (A: 010, B: 001, C: 100), what is the out-degree of vertex B (Row 2)?
A. 0
B. 3
C. 1
D. 2

A

C. 1

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

A graph with very few edges relative to the number of vertices is called:
A. Sparse
B. Regular
C. Complete
D. Dense

A

A. Sparse

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

Given the following Adjacency Matrix for a directed graph (A: 010, B: 001, C: 100), what is the in-degree of vertex A?
A. 2
B. 1
C. 0
D. 3

A

B. 1

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

True or False: Removing an edge in an Adjacency List takes O(1) time in the worst case.

A

FALSE

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

For a sparse graph, which representation is generally more space-efficient?
A. Incidence Matrix
B. Adjacency Matrix
C. Adjacency List
D. Edge Matrix

A

C. Adjacency List

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

A graph where the number of edges is close to n² is called:
A. Acyclic
B. Sparse
C. Dense
D. Bipartite

A

C. Dense

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

Fill in the Blanks: In an adjacency matrix M, the entry M{ij} is set to 1 (or true) specifically if vertex i is _____ to vertex j.

A

adjacent

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

In an Adjacency Matrix representation of a graph with n vertices, the space complexity is:
A. O(n²)
B. O(log n)
C. O(n)
D. O(n + m)

A

A. O(n²)

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

The diagonal entries of an adjacency matrix for a simple graph (no self-loops) are all:
A. 0
B. 1
C. n
D. Undefined

A

A. 0

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

Fill in the Blanks: Check if edge (u, v) exists (Matrix) to _____.

A

O(1)

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

Fill in the Blanks: Iterate all neighbors of u (List) to _____.

A

O(degree(u))

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

Fill in the Blanks: Space Complexity (Matrix) to _____.

17
Q

Fill in the Blanks: Space Complexity (List) to _____.

18
Q

Fill in the Blanks: Iterate all neighbors of u (Matrix) to _____.

19
Q

In an adjacency matrix M for an unweighted undirected graph, if M₍ᵢⱼ₎ = 1, then:
A. There is no edge between i and j
B. There is an edge between i and j
C. i has degree zero
D. j has degree zero

A

B. There is an edge between i and j

20
Q

Fill in the Blanks: Unlike unweighted graphs which use binary values, an adjacency matrix for a weighted graph stores the specific _____ (such as cost, distance, or capacity) in the corresponding matrix cell.