This file contains hidden or 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
| 'use strict'; | |
| /* | |
| * Binary search tree with in-order iteration. | |
| * http://greim.github.io/gen/dist/00-intro.html | |
| */ | |
| class Tree { | |
| add(value) { | |
| if (this.root) this.root.add(value); |
This file contains hidden or 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
| 'use strict'; | |
| function BinarySearchTree() { | |
| this.root = null; | |
| } | |
| BinarySearchTree.prototype.insertNode = function (val) { | |
| var node = { | |
| data : val, |
This file contains hidden or 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
| 'use strict'; | |
| class Node { | |
| constructor(data) { | |
| this.data = data; | |
| this.left = undefined; | |
| this.right = undefined; | |
| } |
This file contains hidden or 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
| #!/usr/bin/env node | |
| const NKEYS = 4; | |
| function arrayOfSize(size) { | |
| var a = Array(size); | |
| for (var i = 0; i < size; i += 1) | |
| a[i] = null; |
NewerOlder