Undirected Graphs Help Center

Learn more

Warning: The hard deadline has passed. You can attempt it, but you will not get credit for it. You are welcome to try it as a learning exercise.

To specify an array or sequence of values in an answer, separate the values in
the sequence by whitespace. For example, if the question asks for the first
ten powers of two (starting at 1), then the following answer is acceptable:

1 2 4 8 16 32 64 128 256 512

If you wish to discuss a particular question and answer in the forums, please
post the entire question and answer, including the seed (which can be used by
the course staff to uniquely identify the question) and the explanation (which
contains the correct answer).

Question 1

(seed = 677584)
Consider the adjacency-lists representation of a graph with 8 vertices and 9 edges:

A: F B E
B: C A F
C: B G F H D
D: C
E: A
F: A B C
G: C
H: C


Here is a graphical representation of the same graph:

(A)-------------(B)-------------(C)-------------(D)
|\ | /|\
| \ | / | \
| \ | / | \
| \ | / | \
| \ | / | \
| \ | / | \
| \ | / | \
| \ | / | \
| \ | / | \
| \ | / | \
| \ | / | \
| \ | / | \
| \ | / | \
| \ | / | \
| \|/ | \
(E) (F) (G) (H)



Run depth-first search (using the adjacency-lists representation) from vertex A. Give the sequence
in which depth-first search discovers (marks) the vertices. This is known as the preorder.
Your answer should be a sequence of 8 uppercase letters, with each letter separated
by whitespae.

Question 2

(seed = 467506)
Consider the adjacency-lists representation of a graph with 8 vertices and 10 edges:

A: B E
B: G E A
C: D H G
D: H C
E: B A F
F: G E
G: F B C
H: D C


Here is a graphical representation of the same graph:

(A)-------------(B) (C)-------------(D)
| / \ |\ |
| / \ | \ |
| / \ | \ |
| / \ | \ |
| / \ | \ |
| / \ | \ |
| / \ | \ |
| / \ | \ |
| / \ | \ |
| / \ | \ |
| / \ | \ |
| / \ | \ |
| / \ | \ |
| / \ | \ |
|/ \| \|
(E)-------------(F)-------------(G) (H)



Run breadth-first search (using the adjacency-lists representation) from vertex A.
Give the sequence in which the vertices are dequeued from the FIFO queue.
Your answer should be a sequence of uppercase letters (starting with A).

Question 3

(seed = 970398)
Consider the adjacency-lists representation of a graph with 10 vertices and 11 edges:

A: G B F
B: G A C
C: B G
D: H
E: J I
F: A G
G: B A F C
H: D
I: J E
J: E I


Here is a graphical representation of the same graph:

(A)-------------(B)-------------(C) (D) (E)
|\ | / / /|
| \ | / / / |
| \ | / / / |
| \ | / / / |
| \ | / / / |
| \ | / / / |
| \ | / / / |
| \ | / / / |
| \ | / / / |
| \ | / / / |
| \ | / / / |
| \ | / / / |
| \ | / / / |
| \ | / / / |
| \|/ / / |
(F)-------------(G) (H) (I)-------------(J)



Compute the connected components of the graph using the depth-first search
algorithm (and start numbering connected component ids with 0). Give the
sequence of the 10 integers in the id[] array for the vertices A through J.

v A B C D E F G H I J
------------------------------------
id[v]
    
You cannot submit your work until you agree to the Honor Code. Thanks!