Question: Please help, Im not sure why my dfs algorithm is not passing test cases and producing inccor#dfs ( a ) performs a depth first search
Please help, Im not sure why my dfs algorithm is not passing test cases and producing inccor#dfsa performs a depth first search starting at node and returns a list of nodes in the order in which they were seen, with start and stop times. Press shift enter to test your code. Ensure that your code has been saved first by pressing shiftenter on the previous cell.
from IPython.core.display import display, HTML
def dfstest:testcases for testgraph, solution in testcases: if solution output: s strsolution Your code output: stroutput failed True displayHTML displayHTML
dfstesttmpipykernelpy:: DeprecationWarning: Importing display from IPython.core.display is deprecated since IPython please import from IPython display
from IPython.core.display import display, HTML
Failed test case: Inputs: graph
Expected Output: Your code output:
Failed test case: Inputs: graph
Expected Output: Your code output:
One or more tests failed.
#INPUT: a node cycle
#OUTPUT:
def dfsvisita u color, d f time, result:du timefor v in au: dfsvisita v color, d f time, resulttimeresult.appendudu fu
def dfsa:color WHITE nf nresult if coloru 'WHITE':result.sortkeylambda x: x # Sort based on discovery timesect output
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
