Skip to content

Commit

Permalink
Revision of the tree
Browse files Browse the repository at this point in the history
  • Loading branch information
BravesDevs committed Jan 10, 2024
1 parent da2489d commit f67283e
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions dsa/Tree/binaryTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,27 +636,25 @@ def convert(node, val, graph):

graph = convert(root, 0, {})

print(graph)

visited = set()
visited.add(start)

minutes = -1

q = [start]

while q:
sz = len(q)
while sz:
node = q.pop(0)

for child in graph[node]:
if child not in visited:
visited.add(child)
q.append(child)

sz -= 1

while len(q):
size = len(q)
while size:
NODE = q.pop(0)
for i in graph[NODE]:
if i not in visited:
visited.add(i)
q.append(i)
size -= 1
minutes += 1

return minutes


Expand Down

0 comments on commit f67283e

Please sign in to comment.