Given a connected undirected graph. Perform a Depth First Traversal of the graph. Note: Use recursive approach.
The first line of the input contains an integer 'T' denoting the number of test cases. Then 'T' test cases follow. Each test case consists of two lines. Description of testcases is as follows: The First line of each test case contains two integers 'N' and 'E' which denotes the no of vertices and no of edges respectively. The Second line of each test case contains 'E' space separated pairs u and v denoting that there is a edge from u to v .
For each testcase, print the nodes while doing DFSstarting from node 0.
You don't need to read input or print anything. Your task is to complete the functiondfs() which takes the Graph and the number of vertices as inputs and returns a list containing the DFS Traversal of the graph starting from the 0th node.
Expected Time Complexity: O(V + E). Expected Auxiliary Space: O(V).
1 <= T <= 100
2 <= N <= 104 1 <= E <= (N*(N-1))/2
Graph doesn't contain multiple edges and self loops.