Question: i want to know that code. When I entered def dfs ( A ) : visited = [ ] answer = [ ] stack =

i want to know that code. When I entered "def dfs(A):
visited =[]
answer =[]
stack =[0]
while stack:
node = stack-pop()
if node not in visited: visited. append (node)
answer. append (node)
stack.extend(A[node]- set(visited))
return answer" in the second code, an error like "Exception has occurred: AssertionError
exception: no description
line 76, in
assert dfs_result ==[0,1,4,5,2,6,3]
AssertionError: " appeared.
 i want to know that code. When I entered "def dfs(A):

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!