posted 6 years ago
So, I am trying to finish up this last part of the binary tree and I just cant seem to get it. According to the instructor theres something wrong in my right parentheses case. Here is the algorithm for the right paren I was following.
The output for pre, post and in I get "-" when my expression is ((3 * (8 - 2)) - (1 + 9))"
Case RPAREN:
if (stack is not empty)
assign current node to child
pop stack and assign to currentNode
if (currentNode.Left is null)
assign child to currentNode.Left
else if currentNode.Right is null
assign child to right node
else
unexpected – generate error
end if
end if
end case
Here is my right paren code
and the whole class just to show