You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from collections import deque
def bfs(root: Node):
queue = deque([root])
while queue:
node = queue.popleft()
# do stuff with node
queue.extend(node.children)
def dfs(node: Node):
for child in node.children:
dfs(child)
Prompt: Traverse through a graph using BFS and DFS. You can either do this iteratively or recursively.
The text was updated successfully, but these errors were encountered: