There are better ways of finding a min in a tree but my main question is why I am unable to change record and keep track of it throughout the trace. I would prefer not to use global variables.
record = sys.maxsize
def findMin(tree, record):
if list(tree.keys())[0] < record:
record = list(tree.keys())[0]
if len(tree[list(tree.keys())[0]]) == 0:
return
else:
for v in tree[list(tree.keys())[0]]:
findMin(v, record)
findMin({100: [{40: [{34: [{15: []}]}], 56: [{67: [{13: [{9:[]}]}]}], 79: [{92: [{84:[{6:[]}]}]}]}]}
, record)
print(record)