Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

NEED HELP WITH THIS QUESTION Consider the following graph. a. Write down the adj

ID: 3826230 • Letter: N

Question

NEED HELP WITH THIS QUESTION

Consider the following graph. a. Write down the adjacency matrix and adjacency lists specifying this graph. (Assume that the matrix rows and columns and vertices in the adjacency lists follow in the alphabetical order of the vertex labels.) b. Starting at vertex a and resolving ties by the vertex alphabetical order, traverse the graph by depth-first search and construct the corresponding depth-first search tree. Give the order in which the vertices were reached for the first time (pushed onto the traversal stack) and the order in which the vertices became dead ends (popped off the stack).

Explanation / Answer

a:

Adjacency matrix:

a

b

c

d

e

f

g

a

0

1

1

1

1

0

0

b

1

0

0

1

0

1

0

c

1

0

0

0

0

0

1

d

1

1

0

0

0

1

0

e

1

0

0

0

0

0

1

f

0

1

0

1

0

0

0

g

0

0

1

0

1

0

0

Adjacency list:

A    -> b c d e

B   -> a c d f

C -> a g

D -> a b f

E -> a g

F -> b d

G -> c e

Depth first search from 'a'

Stack contents step by step

1)

a

2)

b

a

3)

d

b

a

4)

f

d

b

a

5)

d

B

A

6)

B

A

7)

A

8)

c

A

9)

e

G

C

a

10

G

C

A

11)

C

A

12)

A

13)empty

So output is abdfcge

a

b

c

d

e

f

g

a

0

1

1

1

1

0

0

b

1

0

0

1

0

1

0

c

1

0

0

0

0

0

1

d

1

1

0

0

0

1

0

e

1

0

0

0

0

0

1

f

0

1

0

1

0

0

0

g

0

0

1

0

1

0

0