I have a binary tree function with 3 pieces of data in each node. They are classified by id numbers. They also hold “Name” and “Mark”
A certain function I’m having problem with is a name searching function, it looks like this:
def findName(tree,name):
if tree==None:
return None
elif tree['name']==name:
return True
else:
findName(tree['right'],name)
findName(tree['left'],name)
I can always find the first name in a tree, but i can’t find any onwards. If I input findName(tree['right'],name) in the python idle I get true if the name is in the tree.
the only way for a function to actually return some data, is if it itself uses a
returnstatement. Yourelse:suite doesn’t contain anyreturnstatements.