Skip to content
Snippets Groups Projects
Select Git revision
  • 5e683840a1c9e4b7aa5038467088f0af64e38eb7
  • main default protected
  • solution
3 results

worker.js

Blame
  • binarySearchTree.js 1.20 KiB
    export const LEFT = 0;
    export const RIGHT = 1;
    
    function opposite(side) {
      return 1 - side;
    }
    
    class BSTNode {
      constructor(element) {
        this.element = element;
        this.parent = undefined;
        this.children = [undefined, undefined];
      }
    
      isLeaf() {
        return false; // TODO
      }
    
      isBranch() {
        return false; // TODO
      }
    
      getSide(element) {
        return LEFT; // TODO
      }
    
      getDescendant(side) {
        return this; // TODO
      }
    
      getAdjacent(side) {
        return this; // TODO
      }
    
      addChild(element) {
        return this; // TODO
      }
    
      swap(other) {
        const swap = this.element;
        this.element = other.element;
        other.element = swap;
      }
    
      disconnect() {
        return undefined; // TODO
      }
    }
    
    export class BinarySearchTree {
      constructor(elements = []) {
        this.root = undefined;
        for (const element of elements) {
          this.add(element);
        }
      }
    
      _find(element) {
        return undefined; // TODO
      }
    
      _findFringe(element) {
        return undefined; // TODO
      }
    
      add(element) {
        // TODO
      }
    
      has(element) {
        return false; // TODO
      }
    
      delete(element) {
        // TODO
      }
    
      enumerate(inclusiveMinimum, exclusiveMaximum) {
        return []; // TODO
      }
    
      toList() {
        return []; // TODO
      }
    }