Skip to content
Snippets Groups Projects
Select Git revision
  • b8dbecd20d9dca28396ed5ebd5836dbd5c3a130e
  • 3.9 default
  • develop
  • 6.0
  • 5.0
  • 4.0
  • scrutinizer-patch-4
  • scrutinizer-patch-3
  • scrutinizer-patch-2
  • scrutinizer-patch-1
  • 3.7
  • 3.8
  • 3.6
  • 3.9_backported
  • 3.8_backported
  • 3.7_backported
  • 3.5
  • 3.6_backported
  • 3.5_backported
  • 3.4
  • 3.3_backported
  • 6.0.4
  • 6.0.3
  • 5.0.7
  • 6.0.2
  • 6.0.1
  • 5.0.6
  • 6.0.0
  • 5.0.5
  • 6.0.0-rc
  • 5.0.4
  • 6.0.0-beta
  • 5.0.3
  • 4.0.6
  • 5.0.2
  • 5.0.1
  • 4.0.5
  • 5.0.0
  • 4.0.4
  • 5.0.0-rc2
  • 5.0.0-rc1
41 results

functions.inc.php

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
      }
    }