Hi people
I am currently working to traverse a tree and do an inorder printing of the tree. Problem is my instructor wants parenthesis around the expressions not the individual numbers.
def printexp(tree):
sVal=""
if tree:
sVal='( ' + printexp(tree.getLeft())
sVal=sVal+str(tree.getRootValue())
sVal= sVal+printexp(tree.getRight()) +' )'
return sVal
That is the current code I have. Any ideas on how to have the parenthesis only on the expressions?