Git Product home page Git Product logo

jasonheecs / js-data-structures Goto Github PK

View Code? Open in Web Editor NEW
3.0 4.0 0.0 334 KB

An npm package containing implementations of various data structures in Javascript.

Home Page: https://www.npmjs.com/package/@jasonheecs/js-data-structures

License: MIT License

JavaScript 100.00%
javascript npm-package data-structures computer-science linked-list doubly-linked-list circular-linked-list binary-search-tree queue stack trie min-heap

js-data-structures's Introduction

Data Structures in Javascript

Build Status Coverage Status

A package containing implementations of various data structures in Javascript. This project is mainly a learning exercise and personal refresher on the common CS data structures, in addition to playing around with test coverage reports with coveralls

Installation

npm install @jasonheecs/js-data-structures --save

Data Structures

Usage

    var {BST} = require('@jasonheecs/js-data-structures');
    var {List} = require('@jasonheecs/js-data-structures');
    var {Trie} = require('@jasonheecs/js-data-structures');

    var bst = new BST();
    bst.add(10);
    bst.add(5);
    bst.add(15);

    console.log(bst.inOrder()); // [5, 10, 15]


    var linkedList = new List();
    linkedList.add(1);
    linkedList.add(2);
    linkedList.add(3);

    console.log(linkedList.search(2)); // Node { value: 2, next: Node { value: 3, next: null } }


    var trie = new Trie();
    trie.addWord('cat');
    trie.addWord('car');
    trie.addWord('dog');

    console.log(trie.find('ca')); 
    /** Node { value: 'a', children: Map {
         't' => Node { value: 't', children: Map {}, isCompleteWord: true },
         'r' => Node { value: 'r', children: Map {}, isCompleteWord: true } },
        isCompleteWord: false } **/

Running unit tests

npm test

To run a specific test file, you can use an extra -- to pass the filename through:
npm test -- test/binary-search-tree-test.js

License

MIT

js-data-structures's People

Contributors

dependabot[bot] avatar jasonheecs avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.