human
Find if possible to visit every nodes in given Graph exactly once based on given conditions | Function to find print path.
If a [ 0 ] is 1.
Printing path.
Seeking for a [ i ] = 0 and a [ i + 1 ] = 1.
Printing path.
If a [ N - 1 ] = 0.
Driver Code.
Given Input.
Function Call"
Solution in Python:
assistant
#Here is code to find if possible to visit every nodes in given Graph exactly once based on given conditions and the other steps required.
 def findpath ( N , a ) :
	if ( a [ 0 ] ) :
		print ( N + 1 )
		for i in range ( 1 , N + 1 , 1 ) :
			print ( i , end = " ▁ " )
		return
	for i in range ( N - 1 ) :
		if ( a [ i ] == 0 and a [ i + 1 ] ) :
			for j in range ( 1 , i + 1 , 1 ) :
				print ( j , end = " ▁ " )
			print ( N + 1 , end = " ▁ " ) ;
			for j in range ( i + 1 , N + 1 , 1 ) :
				print ( j , end = " ▁ " )
			return
	for i in range ( 1 , N + 1 , 1 ) :
		print ( i , end = " ▁ " )
	print ( N + 1 , end = " ▁ " )
if __name__ == ' _ _ main _ _ ' :
	N = 3
	arr = [ 0 , 1 , 0 ]
	findpath ( N , arr )