javascript-tools-algorithm

1.0.2 • Public • Published

JavaScriptTools

A library provides JavaScript algorithm functions for all uses

  • Priority Queue
  • coming soon...

Priority Queue Example

let isMinHeapTree = true;
let q = new PriorityQueue(isMinHeapTree); // true => min heap tree, false => max heap tree
 
q.push(5); // => [ null, 5 ]
q.push(3); // => [ null, 5, 3 ]
q.push(8); // => [ null, 8, 3, 5 ];
q.push(1); // => [ null, 8, 3, 5, 1 ]
 
q.pop(); // Pop: 8 => [ null, 5, 3, 1 ]
q.pop(); // Pop: 5 => [ null, 3, 1 ]
q.pop(); // Pop: 3 => [ null, 1 ]
q.pop(); // Pop: 1 => [ null ]
q.pop(); // Pop: null => [ null ]

/javascript-tools-algorithm/

    Package Sidebar

    Install

    npm i javascript-tools-algorithm

    Weekly Downloads

    9

    Version

    1.0.2

    License

    ISC

    Unpacked Size

    5.53 kB

    Total Files

    4

    Last publish

    Collaborators

    • nosensezzz