Skip to content

Instantly share code, notes, and snippets.

@verdi327
Created July 2, 2019 14:46
Show Gist options
  • Save verdi327/4372c9eee4a3331ffe1d12d0dacb849c to your computer and use it in GitHub Desktop.
Save verdi327/4372c9eee4a3331ffe1d12d0dacb849c to your computer and use it in GitHub Desktop.
dfs-postorder.js
postOrder(result=[]) {
if (!this.left && !this.right) {
return result.push(this.key);
}
if (this.left) {
this.left.postOrder(result);
}
if (this.right) {
this.right.postOrder(result);
}
result.push(this.key);
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment