Graphs and Their Representations Flashcards

1
Q

What is a graph in computer science?

A

A graph is a mathematical object modeling a binary relation over a finite set, consisting of vertices (nodes) and edges (connections).

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

What are the components of a graph?

A

Vertices (nodes) and edges (links between nodes).

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

What is a directed graph (digraph)?

A

A graph where edges have direction, representing asymmetric relationships.

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

What is an undirected graph?

A

A graph where edges are bidirectional, representing symmetric relationships.

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

How is an edge drawn in an undirected graph?

A

As a straight line without an arrow.

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

What two features are excluded in graphs for this class?

A

Self-loops and multi-edges.

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

What is a self-loop in a graph?

A

An edge that connects a vertex to itself.

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

What are multi-edges in a graph?

A

Multiple edges between the same two vertices.

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

Give examples of real-world systems modeled as graphs.

A
  1. Computer networks
  2. Social networks
  3. Ecological networks
  4. Electrical circuits
  5. Programs
  6. Mapping systems like Google Maps.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What do nodes and edges represent in a computer network graph?

A

Nodes are servers; edges are communication links.

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

What do nodes and edges represent in a social network graph?

A

Nodes are people; edges are social relationships (e.g., friendships).

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

Name some common problems solved using graph algorithms.

A
  1. Graph traversal
  2. Cycle detection
  3. Node ranking
  4. Shortest path finding
  5. Spanning trees
  6. Flows.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is an adjacency matrix?

A

A square matrix where each cell A[i][j] is 1 if there is an edge from node i to node j, otherwise 0.

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

What is the space complexity of an adjacency matrix?

A

O(n^2), where n is the number of vertices.

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

Why is the adjacency matrix inefficient for sparse graphs?

A

Because most entries are zero, wasting space.

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

What is an adjacency list?

A

A list where each node points to a list of its adjacent (neighbor) nodes.

17
Q

What is the space complexity of an adjacency list?

A

O(n + m), where n is the number of vertices and m is the number of edges.

18
Q

When should you use an adjacency list over a matrix?

A

When the graph is sparse.

19
Q

What is the incidence matrix (briefly mentioned)?

A

A node-edge matrix that connects graph theory with linear algebra (e.g., graph Laplacian).

20
Q

What is graph sparsity?

A

When a graph has far fewer edges than the maximum possible, which is common in real-world graphs.

21
Q

Why are real-world graphs often sparse?

A

Most entities (e.g., people or servers) connect to only a limited number of other entities.