Question 1: Here are the adjacency lists for an undirected graph:
I call DFS(A). Suppose the DFS’s action is to print the character of the node before it visits its children, and after it visits its children. To be precise, each node that gets visited will have its character printed exactly twice. What are the characters printed, in the order in which they are printed (just enter a single string with no spaces)?
A - Print A, recursively call on C and D | C - Print C, recursively call on A and E | | A - Already visited | | E - Print E, recursively call on C | | | C - Already visited | | E - E returns -- print E | C - C returns -- print C | D - Print D, recursively call on A | | A - Already visited | D - Print D A - Print ASo the answer is "ACEECDDA".
Question 2: How many connected components are in this graph?