Skip to content

Instantly share code, notes, and snippets.

@Giagnus64
Last active February 26, 2020 22:27
Show Gist options
  • Select an option

  • Save Giagnus64/d44f332114b0607e1ce31e65d87ea4bf to your computer and use it in GitHub Desktop.

Select an option

Save Giagnus64/d44f332114b0607e1ce31e65d87ea4bf to your computer and use it in GitHub Desktop.
PostOrder Helper for DFS
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