Last active
February 26, 2020 22:27
-
-
Save Giagnus64/d44f332114b0607e1ce31e65d87ea4bf to your computer and use it in GitHub Desktop.
PostOrder Helper for DFS
This file contains hidden or 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
| const postOrderHelper = node => { | |
| //recursively call function on all node children FIRST | |
| if (node.children.length !== 0) { | |
| node.children.forEach(child => { | |
| postOrderHelper(child); | |
| }); | |
| } | |
| //push value onto array | |
| treeValues.push(node.value); | |
| return true; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment