human
What is a code to dFS for a n and the other steps required given the following:
DFS for a n | DFS on tree.
Printing traversed node.
Traversing adjacent edges.
Not traversing the parent node.
Driver Code.
Number of nodes.
Adjacency List.
Designing the tree.
Function call"
Solution in Python:
assistant
#Here is code to dFS for a n and the other steps required.
 def dfs ( List , node , arrival ) :
	print ( node )
	for i in range ( len ( List [ node ] ) ) :
		if ( List [ node ] [ i ] != arrival ) :
			dfs ( List , List [ node ] [ i ] , node )
if __name__ == ' _ _ main _ _ ' :
	nodes = 5
	List = [ [ ] for i in range ( 10000 ) ]
	List [ 1 ] . append ( 2 )
	List [ 2 ] . append ( 1 )
	List [ 1 ] . append ( 3 )
	List [ 3 ] . append ( 1 )
	List [ 2 ] . append ( 4 )
	List [ 4 ] . append ( 2 )
	List [ 3 ] . append ( 5 )
	List [ 5 ] . append ( 3 )
	dfs ( List , 1 , 0 )