Eroxl's Notes
Practice 12 (CPSC 221)

Problem 1

Suppose new a friend tells you about their favourite simple, connected, undirected graph that has 7 vertices and 29 edges. Which of the following is true?

  • [x] (a) The new friend is lying. No such graph can exist.
  • [ ] (b) The new friend is boring. There are many different graphs like that.
  • [ ] (c) The new friend is dazzling. There is only one graph like that!

Problem 2

A simple, connected, undirected graph contains 66 edges.

The least upper bound for the number of vertices is:

Least upper bound

The greatest lower bound for the number of vertices is:

Greatest lower bound

(Note that each of the bounds should be a feasible number of vertices.)

Could the graph be complete?

  • [x] (a) Yes
  • [ ] (b) No

Problem 3

Suppose a simple connected undirected graph has vertices whose degrees are given in the following table:

Vertex Degree
0 4
1 4
2 3
3 1
4 1
5 1
6 1
7 1
8 1
9 1

The graph is sparse so it should not be represented with an adjacency matrix, additionally, it's not complete as there are too few edges, there are also not enough edges to form a cycle as the graph is connected, meaning we only have option a.

What can be said about the graph?

  • [x] (a) Depth first search would produce no back edges.
  • [ ] (b) It is complete.
  • [ ] (c) It should be represented using an adjacency matrix.
  • [ ] (d) It has a cycle.

Problem 4

Suppose a simple connected undirected graph has vertices whose degrees are given in the following table:

Vertex Degree
0 4
1 4
2 3
3 3
4 1
5 1
6 1
7 1
8 1
9 1

What can be said about the graph?

  • [ ] (a) It is complete.
  • [ ] (b) It should be represented using an adjacency matrix.
  • [x] (c) It has a cycle.
  • [ ] (d) Depth first search would produce no back edges.

Problem 5

Suppose a simple connected undirected graph has vertices whose degrees are given in the following table:

Vertex Degree
0 5
1 4
2 3
3 1
4 1
5 1
6 1
7 1
8 1
9 1

What can be said about the graph?

  • [ ] (a) It has a cycle.
  • [x] (b) This graph cannot exist.
  • [ ] (c) It should be represented using an adjacency matrix.
  • [ ] (d) Depth first search would produce no back edges.

Problem 6

Suppose a simple connected undirected graph has vertices whose degrees are given in the following table:

Vertex Degree
0 3
1 3
2 3
3 1
4 1
5 1
6 1
7 1
8 1
9 1

What can be said about the graph?

  • [ ] (a) It should be represented using an adjacency matrix.
  • [ ] (b) Depth first search would produce no back edges.
  • [ ] (c) It has a cycle.
  • [x] (d) No such graph can exist.

Problem 7

Suppose we run depth first search on a connected, undirected graph with n vertices and edges. How many edges will be labelled “back” edges?

  • [ ] (a)
  • [ ] (b)
  • [ ] (c)
  • [ ] (d)
  • [x] (e)

Problem 8

For a simple connected graph with vertices and edges, what is the tightest worst case running time for removing a vertex, if the graphs is represented with Edge List, Adjacency List, Adjacency Matrix (assume no resizing needed), respectively?

  • [ ] (a)
  • [x] (b)
  • [ ] (c)

Problem 9

For a simple connected graph G with 51 vertices, which of the following options cannot be the number of edges of G?

  • [x] (a) 1328
  • [ ] (c) All of the options are possible
  • [ ] (d) 69
  • [ ] (e) 510
  • [x] (f) 48

Problem 10

Suppose G is fully connected (every vertex has an edge to every other vertex). What is the runtime of adding a vertex to the graph such that the graph remains fully connected. Assume that the graph is represented using an adjacency list and has n vertices and m edges. (Assume constant time when inserting to list)

  • [ ] (a)
  • [ ] (b)
  • [x] (c)
  • [ ] (d)

Problem 11

For a simple connected graph with 45 vertices, which of the following options cannot be the number of edges of G?

  • [ ] (a) 69
  • [x] (b) 1328
  • [ ] (c) 48
  • [ ] (d) 510

Problem 12

One version of DFS proceeds as: (1) Push the root with no associated edge. (2) While the stack is not empty, pop the next node and its associated edge (if any); if it has been marked as visited, skip it; otherwise, mark it as visited, mark its attached edge (if any) as a tree edge, and for each node adjacent to it, push the adjacent node along with the edge connecting to it from the current node.

Now, consider two vertices x and y that were simultaneously on the stack at some point during execution of DFS from vertex s in an undirected graph. Which of the following is/are true when DFS completes?

I. The number of edges on the shortest path from s to x is at most one more than the number of edges on the shortest path from s to y.

II. The difference in the number of discovery (tree) edges on the path from s to x and from s to y is at least 1.

III. There is a path from x to y.

  • [ ] (a) Two of the items are true.
  • [ ] (b) None of the items is true.
  • [ ] (c) Item II. is true.
  • [x] (d) Item III. is true.
  • [ ] (e) Item I. is true.

Problem 13

Suppose G is fully connected (every vertex has an edge to every other vertex). What is the runtime of adding a vertex to the graph such that the graph remains fully connected. Assume that the graph is represented using an adjacency matrix and has n vertices and m edges.(Assume no resizing needed)

  • [x] (a)
  • [ ] (b)
  • [ ] (c)
  • [ ] (d)