dstructures.js
v1.0.5
Published
Data structures and algorithms written in JavaScript
Downloads
39
Maintainers
Readme
DStructures.js
Welcome to DStructures.js! This package provides implementations of various data structures and algorithms in JavaScript. Navigate through specific directories to get a deeper understanding of each component.
Table of Contents
Data Structures
(Note: For specific details on each data structure, click on the respective link.)
Algorithms
(Note: For specific details on each algorithm, click on the respective link.)
Installation
To utilize these data structures and algorithms in your projects:
npm install --save dstructures.js
Getting Started
Here's a simple example to get started with the Linked List data structure:
const { LinkedList } = require('DStructures.js');
const list = new LinkedList();
list.addLast(1);
list.addLast(2);
list.addLast(3);
console.log(list.toArray()); // Outputs: [1, 2, 3]
For more detailed usage and API descriptions, please refer to the individual READMEs of each data structure or algorithm.
Require
const {
BinarySearchTree, BinarySearchTreeNode,
DoublyLinkedList, DoublyLinkedListNode,
Graph, GraphVertex,
HashMap,
HashSet,
Heap, MinHeap, MaxHeap,
LinkedList, LinkedListNode,
PriorityQueue, PriorityQueueNode,
Queue,
Stack,
binarySearch,
bubbleSort,
dijkstra,
insertionSort,
mergeSort,
quickSort,
selectionSort,
} = require('dstructures.js');
Import
import {
BinarySearchTree, BinarySearchTreeNode,
DoublyLinkedList, DoublyLinkedListNode,
Graph, GraphVertex,
HashMap,
HashSet,
Heap, MinHeap, MaxHeap,
LinkedList, LinkedListNode,
PriorityQueue, PriorityQueueNode,
Queue,
Stack,
binarySearch,
bubbleSort,
dijkstra,
insertionSort,
mergeSort,
quickSort,
selectionSort,
} from 'dstructures.js';
Extend
Data structures are implemented as ES6 classes and can be extended for additional functionality.
const { Graph } = require('dstructures.js');
class CustomGraph extends Graph {
shortestPath(start, end) {
// code here
}
}