Created
November 27, 2017 03:48
-
-
Save veryjos/851e992b7e1d754050b581e65b14a3e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/ | |
Add | |
/ \ | |
1 4 | |
Start at print node, postorder traversal: | |
| Node: Print | |
| | |
| Visit left | |
| | Node: Add | |
| | | |
| | Visit left | |
| | | Node: 1 | |
| | | | |
| | | stack.push(1) | |
| | | |
| | Visit right | |
| | | Node: 4 | |
| | | | |
| | | stack.push(4) | |
| | | |
| | RighthandValue = stack.pop() | |
| | LefthandValue = stack.pop() | |
| | | |
| | Push RighthandValue + LefthandValue | |
| | |
| ValueToPrint = stack.pop() | |
| Print(ValueToPrint) | |
| | |
| Visit Right | |
end traversal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment