npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@raikuxq/alg-ds

v1.2.5

Published

Documentation app: [raikuxq-algorithms.netlify.app/guide](https://raikuxq-algorithms.netlify.app/guide)

Downloads

16

Readme

Common algorithms and data structures.

Written in TypeScript, tested with Jest.

Documentation

Documentation app: raikuxq-algorithms.netlify.app/guide

Usage as package

Install by using any of these commands:

  • yarn add @raikuxq/alg-ds
  • npm install @raikuxq/alg-ds --save

Usage as repository

Clone this repository and install dependencies by using yarn command.

  • yarn test - run all tests via jest
  • yarn dev - run in dev mode via nodemon (src/index.ts is an entrypoint)
  • yarn build - compile ts sources into js files
  • yarn start - build and run in production mode
  • yarn lint - lint check via eslint
  • yarn lint:fix - fix source files via eslint

Navigation

Algorithms

Utils

memoize — Memoization util function.

Searching

binary-search [ tests ] — Binary searching algorithm. Time: O(log(n)).

Math

factorial [ tests ] — Recursive O(n!) and memoized O(n) factorial implementation.

fibonacci [ tests ] — Recursive O(n!) and memoized O(n) factorial implementation.

transpose-matrix [ tests ] — Transpose N*N matrix util function.

Sorting algorithms

bubble-sort [ tests ] — Time: O(n^2) worst, O(n^2) avg, O(n) best. Memory: O(1) worst.

selection-sort [ tests ] — Time: O(n^2) worst, O(n^2) avg, O(n^2) best. Memory: O(1) worst.

insertion-sort [ tests ] — Time: O(n^2) worst, O(n^2) avg, O(n) best. Memory: O(1) worst.

merge-sort [ tests ] — Time: O(nlog(n)) worst, O(nlog(n)) avg, O(n*log(n)) best. Memory: O(n) worst.

quick-sort [ tests ] — Time: O(n^2) worst, O(nlog(n)) avg, O(nlog(n)) best. Memory: O(1) worst.

Linear data structures

Interfaces

ILinearStorage — Contains common methods of linear data structures.

ILinearStorageRA — Allows random access (from end, from start, by index). Extends ILinearStorage interface.

IConvertableToArray — Contain methods for converting from/into array.

Linked List

Interfaces

ILinkedList — Contains basic linked lists operations. Extends ILinearStorageRA and IConvertableToArray interface.

Implementation

AbstractLinkedList — Common logic for both single and double linked lists. Implements ILinearStorageRA interface.

SingleLinkedList [ tests ] — Extends abstract linked list with implementation of one-way linking.

DoubleLinkedList [ tests ] — Extends abstract linked list with implementation of two-way linking.

IterableSingleLinkedList [ tests ] — Extends single linked list with iterator implementation. Implements IIterable interface.

IterableDoubleLinkedList [ tests ] — Extends double linked list with implementation of two-way linking. Implements IBiDirectIterable interface.

Looped Array

Interfaces

IArrayFacade — Contains basic array operations. Extends ILinearStorageRA interface. Extends IConvertableToArray interface.

Implementation

LoopedArray [ tests ] — Overwrites data on capacity overflow.

Stack

Implementation

Stack [ tests ] — LIFO data structure. Implements ILinearStorage interface.

Queue

Implementation

Queue [ tests ] — FIFO data structure. Implements ILinearStorage interface.

Non linear data structures

HASH Table

Interfaces

IKeyValueStorage — Contains basic key-value storages operations.

Implementation

HashTableNode — Contains key, data and isDeleted properties.

HashTable [ tests ] — Implementation of open addressing hash table using quadratic probing

Graph

Interfaces

IGraph — Contains basic graph operations.

IGraphIterator — Extends default iterator with init and getPath methods.

IGraphIterationStrategy — Iteration strategies which are used in shortest-path, has-path.

Implementation

GraphEdge — Contains from/to links and edge weight.

AbstractGraph — Common logic for both directed and undirected graphs.

DirectedGraph [ tests ] — In case of directed graph A->B and B->A edges are not the same.

UndirectedGraph [ tests ] — In case of undirected graph A->B and B->A are equal.

Graph Iterators

BreadthFirstSearchIterator — Traversal method for unweighted graphs, built on queue.

DepthFirstSearchIterator — Traversal method for unweighted graphs, built on stack.

DijkstraMethodIterator — Traversal method for weighted graphs, built on finding the minimal cost.

Graph Presenter

presenter-adjacency-lists [ tests ] — Representation of graph as an adjacency list (using Map).

presenter-adjacency-matrix [ tests ] — Representation of graph as an adjacency matrix (using Array N*N).

Graph Searching

has-path (BFS/DFS) [ tests ] — Search for the existence of a path between two vertices.

shortest-path (BFS/Dijkstra) [ tests ] — Search for one of several shortest paths between two vertices.

Graph Creators

create-graph-from-matrix [ tests ] — Convert a matrix N*N into a graph instance.

Graph Transposing

transpose-directed-graph [ tests ] — Transpose a directed graph (undirected graphs are symmetrical already).

Binary trees

IBinaryTree — Contains basic binary tree operations.

Implementation

AbstractBinaryNode — Contains left/right/parent links and node data.

AbstractBinaryTree — Common logic for all types of binary trees.

BinarySearchNode — Same as abstract binary node.

BinarySearchTree — Implementation of unbalanced binary search tree. Each node in left subtree is smaller and each node in right subtree is larger than the node data. Extends AbstractSearchTree.

RandBinarySearchNode — Have a rank attribute. Extends BinarySearchNode.

RandBinarySearchTree — Implementation of randomized binary search tree, which gives expected log(N) height. INSERTION have a 1/N+1 probability of inserting into root. Extends BinarySearchTree.