Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Node.prototype.push = function(n) {
- if (this.value === null) {
- this.value = n
- return
- }
- if (n < this.value) {
- if (this.left === null) {
- this.left = new Node(n)
- } else {
- this.left.push(n)
- }
- } else {
- if (this.right === null) {
- this.right = new Node(n)
- } else {
- this.right.push(n)
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement