Typing Course

Feedback
Settings
AccuracySpeedTimeErrors

100%

0WPM

0CPM

0s

0/0

"""⏎
branch as far as possible before backtracking.⏎
Time Complexity: O(E + V)⏎
E = Number of edges⏎
V = Number of vertices (nodes)⏎
Pseudocode: https://en.wikipedia.org/wiki/Depth-first_search⏎
"""⏎
def dfs(graph, start, path=[]):⏎
"""⏎
Depth first search that recursively searches the path. Backtracking occurs⏎
only when the last node in the path is visited.⏎
:param graph: A dictionary of nodes and edges.⏎
:param start: The node to start the recursive search with.⏎
:param path: A list of edges to search.⏎
:rtype: A boolean indicating whether the node is included in the path.⏎
"""⏎
if start not in graph or graph[start] is None or graph[start] == []:⏎
return None⏎
path = path + [start]⏎
for edge in graph[start]:⏎
if edge not in path:⏎
path = dfs(graph, edge, path)⏎
return path⏎

This course is for Pro members.

Check this out! Our plans start at only 2.69 USD per month

Upgrade your account and SAVE 40% NOW!
Already have a Pro account? Sign in
`~
1!
2@
3#
4$
5%
6^
7&
8*
9(
0)
-_
=+
backspace
tab
q
w
e
r
t
y
u
i
o
p
[{
]}
\|
capslock
a
s
d
f
g
h
j
k
l
;:
'"
enter
lshift
z
x
c
v
b
n
m
,<
.>
/?
rshift
fn
ctrl
lalt
lmeta
space
rmeta
ralt