Git Product home page Git Product logo

js-algorithms's Introduction

๐Ÿš€ Algorithms License GitHub issues


ยฉ xkcd.com

Playground for algorithms in JavaScript. This is a child project of js-library and the twin project of js-data-structures.

๐Ÿ“ฐ Description

This project is just a playground for any algorithm that doesn't fit in any of those projects,

๐Ÿ”ฆ Searching

๐ŸŒ– Merging

๐Ÿฐ Partitioning

๐Ÿ‘‡ Selection

๐Ÿ“ถ Sorting

โš–๏ธ Comparison sorting

๐Ÿ’ค Integer sorting

๐Ÿ”ฃ Strings

Nothing yet.

๐Ÿ”ช Hashing

Nothing yet.

๐Ÿ“ Geometry

๐ŸŒ Graphs

๐Ÿ”ข Numbers

๐Ÿ”ฃ Arithmetic

2๏ธโƒฃ 3๏ธโƒฃ 5๏ธโƒฃ 7๏ธโƒฃ Number theory

๐Ÿš Integer sequences

๐ŸŽฒ Randomness

๐Ÿง  Hard problems

โ†”๏ธ Sytems of equalities and inequalities

๐Ÿงน Combinatorics

Those packages aim to provide code bricks that are as generic as possible. Some examples are a Gauss-Jordan method that can work with any number model, a Karatsuba algorithm that can handle any input size, a Graham Scan algorithm that works with clockwise or counter clockwise ordering, and a Monotone Chain algorithm that can be used as a triangulation algorithm without any change.

๐Ÿ“œ Reference

A list of links and projects focusing on algorithm implementation.

โ˜• Projects implementing algorithms in JavaScript

๐Ÿฆš Projects implementing algorithms in other languages

๐Ÿ”— Others

js-algorithms's People

Contributors

gitter-badger avatar greenkeeperio-bot avatar make-github-pseudonymous-again avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

js-algorithms's Issues

Planar Separator

See "A Separator Theorem for Planar Graphs" by Lipton and Tarjan.

Karp-Luby sampling

Linear time measure approximation of a set union given oracles for uniform sampling on the multiset union and membership testing on the insertion-order labeled set union.

measure: |S| e.g. volume, cardinality, ...

set union: U_i S_i

uniform sampling on the multiset union: Sample (y, k) from U_i { (x, i) : x in S_i } uniformly at random.

membership testing on the union-order labeled set union: Test whether (y, k) belongs to U_i { (x, i) : x in S_i, x not in S_j for j < i }. Can be implemented as testing whether y belongs to { x in S_k : x not in S_j for j < k } in general.

References

  • 1983 Karp, Luby Monte-Carlo algorithms for enumeration and reliability problems
  • 1989 Karp, Luby, Madras Monte-Carlo approximation algorithms for enumeration problems

5-list-coloring of planar graphs

Reference

@Article{thomassen1994every,
title={Every planar graph is 5-choosable},
author={Thomassen, Carsten},
journal={Journal of Combinatorial Theory Series B},
volume={62},
number={1},
pages={180--181},
year={1994},
publisher={Academic Press, Inc. Orlando, FL, USA}
}

Algorithm

Input:
A triangulation T with outer boundary cycle C,
two adjacent vertices on C named u and v
and color assignment L for T such that
L(u) = {1},
L(v) = {2},
|L(o)| >= 3 for o in C - {u, v}, and
|L(i)| >= 5 for i in T - C.

Output: A proper coloring of T.

Steps:

  1. Color u with the color in L(u) and color v with the color in L(v).

  2. Base case: |T| = |C| = 3, color o in C - {u,v} with one of the colors in L(o) - L(u) - L(v).

  3. If there is a chord (s,t) of C then split C along this chord into two
    smaller cycles, given two strictly smaller triangulations A and B.
    Let A be the triangulation that contains (u,v).
    Recursively color B with L.
    This gives a color assigment to s and t of 1' and 2' respectively. Let L'(s) = 1'
    and L'(t) = 2' and L'(x) = L(x) for all other vertices in B.
    Recursively color B with L'.

  4. There is no chord. Let t != v be the other vertex of C that is adjacent to u.
    Let L'(t) = L(t) - L(u). L'(t) contains at least 2 colors {x,y}.
    For all vertices f adjacent to t that are in T - C let L'(f) = L(f) - {x,y}.
    For all other vertices x of T let L'(x) = L(x).
    Recursively color T - {t} with L'.
    Let s != u (could be v) be the other adjacent vertex of t on C and x be its
    assigned color without loss of generality. Extend the coloring of T - {t} to a coloring of T
    by coloring t with y.

explore other implementations of binomial heaps

  1. use a backreference to keep track of nodes instead of swapping childrens
    • faster because we only need to swap values and backreferences
    • additional memory used
  2. implementation only supporting push pop and merge

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.