New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ds-in-js

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ds-in-js

- Stack - Queue - Linked List - Tree - Graph - Hash Table

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Basic Datastructures introduced in javascript

  • Stack
  • Queue
  • Linked List
  • Tree
  • Graph
  • Hash Table

Installation and Usage

npm install ds-in-js --save-dev

Stack:

const { Stack } = require("ds-in-js");

const stack = new Stack();
stack.push(1);
stack.push(2);
const data = stack.pop(); // 2
const top = stack.peek(); // 1

Queue:

const { Queue } = require("ds-in-js");

const queue = new Queue();
queue.enqueue(1);
queue.enqueue(2);
const data = queue.dequeue(); // 1
const top = queue.peek(); // 2

Linked List

const { LinkedList } = require("ds-in-js");
const lList = new LinkedList([1, 2, 3]);
console.log(lList.getElementAtStart());

Binary Search Tree:

const { BST } = require("ds-in-js");

const bst = new BST();
bst.insert(2);
bst.insert(1);
const node = bst.search(1); // { data: 1, left: null, right: null }
bst.delete(1);

Graph

const { Graph } = require("ds-in-js");
const graph = new Graph();

/*
    a---b
    |  /    
    | /
    c
*/

graph.addVertex("a");
graph.addVertex("b");
graph.addVertex("c");

graph.addEdge("a", "c"); // add weight using graph.addEdge('a', 'c', 10)
graph.addEdge("c", "b");
graph.addEdge("a", "b");

const output = [];
graph.dfs("a", vertex => output.push(vertex.name)); // ['a', 'c', 'b']

Keywords

FAQs

Package last updated on 19 Nov 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc