Created
July 2, 2019 14:46
-
-
Save verdi327/4372c9eee4a3331ffe1d12d0dacb849c to your computer and use it in GitHub Desktop.
dfs-postorder.js
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
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