# data-structure-typed

Javascript Data Structure, TypeScript Data Structure Library

## install

### yarn

```bash
yarn add data-structure-typed
```

### npm

```bash
npm install data-structure-typed
```

## api docs

[//]: # ([api docs]&#40;https://data-structure-typed-docs.vercel.app/&#41;)

<nav class="tsd-navigation"><a href="https://data-structure-typed-docs.vercel.app/modules.html" class="current"><span>data-<wbr/>structure-<wbr/>typed</span></a>
<ul class="tsd-small-nested-navigation">

[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/enums/CP.html"><span>CP</span></a></li>)

[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/enums/FamilyPosition.html"><span>Family<wbr/>Position</span></a></li>)

[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/enums/LoopType.html"><span>Loop<wbr/>Type</span></a></li>)
<li><a href="https://data-structure-typed-docs.vercel.app/classes/AVLTree.html"><span>AVLTree</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/AVLTreeNode.html"><span>AVLTree<wbr/>Node</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/AaTree.html"><span>Aa<wbr/>Tree</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/AbstractEdge.html"><span>Abstract<wbr/>Edge</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/AbstractGraph.html"><span>Abstract<wbr/>Graph</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/AbstractVertex.html"><span>Abstract<wbr/>Vertex</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/ArrayDeque.html"><span>Array<wbr/>Deque</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/BST.html"><span>BST</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/BSTNode.html"><span>BSTNode</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/BTree.html"><span>BTree</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/BinaryIndexedTree.html"><span>Binary<wbr/>Indexed<wbr/>Tree</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/BinaryTree.html"><span>Binary<wbr/>Tree</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/BinaryTreeNode.html"><span>Binary<wbr/>Tree<wbr/>Node</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/Character.html"><span>Character</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/CoordinateMap.html"><span>Coordinate<wbr/>Map</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/CoordinateSet.html"><span>Coordinate<wbr/>Set</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/Deque.html"><span>Deque</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/DirectedEdge.html"><span>Directed<wbr/>Edge</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/DirectedGraph.html"><span>Directed<wbr/>Graph</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/DirectedVertex.html"><span>Directed<wbr/>Vertex</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/DoublyLinkedList.html"><span>Doubly<wbr/>Linked<wbr/>List</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/DoublyLinkedListNode.html"><span>Doubly<wbr/>Linked<wbr/>List<wbr/>Node</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/Heap.html"><span>Heap</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/Matrix2D.html"><span>Matrix2D</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/MatrixNTI2D.html"><span>MatrixNTI2D</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/MaxHeap.html"><span>Max<wbr/>Heap</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/MaxPriorityQueue.html"><span>Max<wbr/>Priority<wbr/>Queue</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/MinHeap.html"><span>Min<wbr/>Heap</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/MinPriorityQueue.html"><span>Min<wbr/>Priority<wbr/>Queue</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/Navigator.html"><span>Navigator</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/ObjectDeque.html"><span>Object<wbr/>Deque</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/PriorityQueue.html"><span>Priority<wbr/>Queue</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/Queue.html"><span>Queue</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/RBTree.html"><span>RBTree</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/SegmentTree.html"><span>Segment<wbr/>Tree</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/SegmentTreeNode.html"><span>Segment<wbr/>Tree<wbr/>Node</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/SinglyLinkedList.html"><span>Singly<wbr/>Linked<wbr/>List</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/SinglyLinkedListNode.html"><span>Singly<wbr/>Linked<wbr/>List<wbr/>Node</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/SplayTree.html"><span>Splay<wbr/>Tree</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/Stack.html"><span>Stack</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/TreeMultiSet.html"><span>Tree<wbr/>Multi<wbr/>Set</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/Trie.html"><span>Trie</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/TrieNode.html"><span>Trie<wbr/>Node</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/TwoThreeTree.html"><span>Two<wbr/>Three<wbr/>Tree</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/UndirectedEdge.html"><span>Undirected<wbr/>Edge</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/UndirectedGraph.html"><span>Undirected<wbr/>Graph</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/UndirectedVertex.html"><span>Undirected<wbr/>Vertex</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/Vector2D.html"><span>Vector2D</span></a></li></ul></nav>

## data structures

Meticulously crafted to empower developers with a versatile set of essential data structures. Our library includes a wide range of data structures:
Binary Tree, Binary Search Tree (BST), AVL Tree, Tree Multiset, Segment Tree, Binary Indexed Tree, Graph, Directed Graph, Undirected Graph, Linked List, Singly Linked List, Doubly Linked List, Queue, Object Deque, Array Deque, Stack, Hash, Coordinate Set, Coordinate Map, Heap, Priority Queue, Max Priority Queue, Min Priority Queue, Trie
<table>
<thead>
  <tr>
    <th>Data Structure</th>
    <th>Derived</th>
    <th>Basic Features</th>
    <th>Additional Features</th>
  </tr>
</thead>

<tbody>
<tr>
    <td>Binary Tree</td>
    <td>AVL Tree, Binary Search Tree, Tree Multiset</td>
    <td>put, has, get, remove, size, insertTo, insertMany, fill, getDepth, getHeight, getMinHeight, getPathToRoot, isBalanced </td>
    <td>getLeftMost, isBST, getSubTreeSizeAndCount, subTreeSum, subTreeAdd, BFS, DFS, DFSIterative, levelIterative, listLevels, getPredecessor, morris,  </td>
  </tr>

  <tr>
    <td>AVL Tree</td>
    <td></td>
    <td>All the features inherited from Binary Tree, balanceFactor, updateHeight, balancePath, balanceLL, balanceLR, balanceRR, balanceRL</td>
    <td></td>
  </tr>

  <tr>
    <td>Binary Search Tree (BST)</td>
    <td></td>
    <td>All the features inherited from Binary Tree, lastKey</td>
    <td>All the features inherited from Binary Tree, lesserSum, allGreaterNodesAdd, balance, isAVLBalanced</td>
  </tr>

  <tr>
    <td>Tree Multiset</td>
    <td></td>
    <td>All the features inherited from Binary Tree</td>
    <td>All the features inherited from Binary Tree</td>
  </tr>

  <tr>
    <td>Segment Tree</td>
    <td></td>
    <td>build, updateNode, querySumByRange</td>
    <td></td>
  </tr>

  <tr>
    <td>Binary Indexed Tree</td>
    <td></td>
    <td>update, getPrefixSum, getRangeSum, BinaryIndexedTree.lowBit</td>
    <td></td>
  </tr>
  <tr>
    <td>Graph</td>
    <td>Directed Graph, Undirected Graph</td>
    <td>getVertex, getVertexId, containsVertex, vertexSet, addVertex, removeVertex, removeAllVertices, containsEdge, setEdgeWeight, getAllPathsBetween, getPathSumWeight, getMinCostBetween, getMinPathBetween, </td>
    <td>dijkstra, dijkstraWithoutHeap, bellmanFord, floyd, tarjan</td>
  </tr>
  <tr>
    <td>Directed Graph</td>
    <td></td>
    <td>All the features inherited from Graph, getEdge, addEdge, removeEdgeBetween, removeEdge, removeAllEdges, incomingEdgesOf, outgoingEdgesOf, degreeOf, inDegreeOf, outDegreeOf, edgesOf, getEdgeSrc, getEdgeDest, getDestinations, edgeSet, getNeighbors, getEndsOfEdge</td>
    <td>All the features inherited from Graph, topologicalSort</td>
  </tr>
  <tr>
    <td>Undirected Graph</td>
    <td></td>
    <td>All the features inherited from Graph, getEdge, addEdge, removeEdgeBetween, removeEdge, degreeOf, edgesOf, edgeSet, getEdgesOf, getNeighbors, getEndsOfEdge</td>
    <td>All the features inherited from Graph</td>
  </tr>
  <tr>
    <td>Singly Linked List</td>
    <td></td>
    <td>length, head, tail, size, get, getNode, findNodeIndex, findNode, find, findIndex, append, push, prepend, insertAt, removeNode, removeAt, insertBefore, sort, insertAfter, shift, pop, merge, clear, slice, reverse, forEach, map, filter, reduce, toArray, toString</td>
    <td></td>

  </tr>
  <tr>
    <td>Hash</td>
    <td>CoordinateSet, CoordinateMap</td>
    <td></td>
    <td></td>
  </tr>
  <tr>
    <td>CoordinateSet</td>
    <td></td>
    <td>has, set, get, delete</td>
    <td></td>
  </tr>
  <tr>
    <td>CoordinateMap</td>
    <td></td>
    <td>has, add, delete</td>
    <td></td>
  </tr>
  <tr>
    <td>Heap</td>
    <td></td>
    <td></td>
  </tr>


  <tr>
    <td>Doubly Linked List</td>
    <td></td>
    <td>size, offerFirst, offerLast, peekFirst, peekLast, pollFirst, pollLast, get, isEmpty, insert, remove, </td>
    <td></td>
  </tr>

[//]: # (  <tr>)

[//]: # (    <td>Matrix</td>)

[//]: # (    <td></td>)

[//]: # (    <td></td>)

[//]: # (    <td></td>)

[//]: # (  </tr>)

  <tr>
    <td>Priority Queue</td>
    <td>Max Priority Queue, Min Priority Queue</td>
    <td>offer, peek, poll, leaf, isEmpty, clear, toArray, clone</td>
    <td>isValid, sort, DFS</td>
  </tr>
  <tr>
    <td>Max Priority Queue</td>
    <td></td>
    <td>All the features inherited from Priority Queue</td>
    <td>All the features inherited from Priority Queue</td>
  </tr>
  <tr>
    <td>Min Priority Queue</td>
    <td></td>
    <td>All the features inherited from Priority Queue</td>
    <td>All the features inherited from Priority Queue</td>
  </tr>
  <tr>
    <td>Queue</td>
    <td>Queue, Dequeue</td>
    <td>offer, poll, peek, peekLast, size, isEmpty, toArray, clear, clone, Queue.fromArray</td>
    <td></td>
  </tr>
  <tr>
    <td>ObjectDeque</td>
    <td></td>
    <td>size, offerFirst, offerLast, pollFirst, peekFirst, pollLast, peekLast, get, isEmpty</td>
    <td></td>
  </tr>
  <tr>
    <td>ArrayDeque</td>
    <td></td>
    <td>offerLast, pollLast, pollFirst, offerFirst, peekFirst, peekLast, get, set, insert, remove, isEmpty</td>
    <td></td>
  </tr>
  <tr>
    <td>Stack</td>
    <td></td>
    <td>isEmpty, size, peek, push, pop, toArray, clear, clone, Stack.fromArray</td>
    <td></td>
  </tr>
  <tr>
    <td>Trie</td>
    <td></td>
    <td>put, has, remove, isAbsPrefix, isPrefix, getAll</td>
    <td></td>
  </tr>
</tbody>

</table>




![complexities](src/assets/complexities-diff.jpg)

![complexities of data structures](src/assets/data-structure-complexities.jpg)

![](src/data-structures/binary-tree/diagrams/bst-rotation.gif)

![](src/data-structures/binary-tree/diagrams/avl-tree-inserting.gif)


![](src/data-structures/graph/diagrams/tarjan.webp)

![](src/data-structures/graph/diagrams/adjacency-list.jpg)

![](src/data-structures/graph/diagrams/adjacency-list-pros-cons.jpg)

![](src/data-structures/graph/diagrams/adjacency-matrix.jpg)

![](src/data-structures/graph/diagrams/adjacency-matrix-pros-cons.jpg)

![](src/data-structures/graph/diagrams/dfs-can-do.jpg)

![](src/data-structures/graph/diagrams/edge-list.jpg)

![](src/data-structures/graph/diagrams/edge-list-pros-cons.jpg)

![](src/data-structures/graph/diagrams/max-flow.jpg)

![](src/data-structures/graph/diagrams/mst.jpg)

[//]: # (![]&#40;src/data-structures/graph/diagrams/tarjan-articulation-point-bridge.png&#41;)

[//]: # (![]&#40;src/data-structures/graph/diagrams/tarjan-complicate-simple.png&#41;)

[//]: # (![]&#40;src/data-structures/graph/diagrams/tarjan-strongly-connected-component.png&#41;)





