Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. Node.prototype.push = function(n) {
  2. if (this.value === null) {
  3. this.value = n
  4. return
  5. }
  6.  
  7. if (n < this.value) {
  8. if (this.left === null) {
  9. this.left = new Node(n)
  10. } else {
  11. this.left.push(n)
  12. }
  13. } else {
  14. if (this.right === null) {
  15. this.right = new Node(n)
  16. } else {
  17. this.right.push(n)
  18. }
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement