bench/ubilabs.js
function loadTree (data) {
      // Just need to restore the `parent` parameter
      self.root = data;

      function restoreParent (root) {
        if (root.left) {
          root.left.parent = root;
          restoreParent(root.left);
        }

        if (root.right) {
          root.right.parent = root;
          restoreParent(root.right);
        }
      }

      restoreParent(self.root);
    }
function loadTree (data) {
      // Just need to restore the `parent` parameter
      self.root = data;

      function restoreParent (root) {
        if (root.left) {
          root.left.parent = root;
          restoreParent(root.left);
        }

        if (root.right) {
          root.right.parent = root;
          restoreParent(root.right);
        }
      }

      restoreParent(self.root);
    }
function loadTree ( data ) { // Just need to restore the `parent` parameter self . root = data ; function restoreParent ( root ) { if ( root . left ) { root . left . parent = root ; restoreParent ( root . left ) ; } if ( root . right ) { root . right . parent = root ; restoreParent ( root . right ) ; } } restoreParent ( self . root ) ; }
Reloads a serialied tree
Reloads a serialied tree