Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. function BinaryTree() {
  2. this.root = null;
  3. }
  4.  
  5. BinaryTree.prototype.addValue = function(value) {
  6. if (this.root == null) {
  7. this.root = new Node(value);
  8. this.root.x = width / 2;
  9. this.root.y = 50;
  10. } else {
  11. this.root.addNode(new Node(value));
  12. }
  13. }
  14.  
  15. BinaryTree.prototype.search = function(value) {
  16. return this.root.search(value);
  17. }
  18.  
  19. BinaryTree.prototype.traverse = function() {
  20. this.root.visit(this.root);
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement