Commit Graph

489 Commits

Author SHA1 Message Date
Oleksii Trekhleb
7f189498cf Update BitWise Operation README. 2018-08-10 18:19:58 +03:00
Ujjwal Aryal
3f963ccc21 Update README.md (#141) 2018-08-10 18:16:39 +03:00
Oleksii Trekhleb
50c025949b Refactor bitwise multiplication. 2018-08-10 18:14:39 +03:00
Ujjwal Aryal
53c7143e07 Create multiply.js (#140)
Multiply Two numbers using Bit-wise Operator.
2018-08-10 17:39:45 +03:00
Oleksii Trekhleb
ff4854e0b8 Simplify PolynomialHash function. 2018-08-09 16:04:59 +03:00
Oleksii Trekhleb
51f496ce2e Add SimplePolynomialHash function. 2018-08-09 15:46:22 +03:00
Oleksii Trekhleb
d5be477bd8 Add Polynomial Hash function. 2018-08-09 15:12:36 +03:00
Oleksii Trekhleb
98a44ea832 Added Polynomial Hash Function. 2018-08-09 07:24:31 +03:00
Oleksii Trekhleb
b3a503aa6d Add unicode based tests for RabinKarp. 2018-08-09 06:10:47 +03:00
Oleksii Trekhleb
e7d22b4883 Use '===' for double check string comparision in RabinKarp. 2018-08-09 06:05:09 +03:00
Oleksii Trekhleb
d303d83673 Use rolling hash function for RabinKarp. 2018-08-09 05:57:53 +03:00
Oleksii Trekhleb
650e3099e5 Merge branches 'issue-102-rabin-karp-fix' and 'master' of https://github.com/trekhleb/javascript-algorithms into issue-102-rabin-karp-fix 2018-08-06 16:55:01 +03:00
Oz Weiss
7c9601df3e Update combinationSum.js (#137)
fixing a few typos in comments
2018-08-06 16:40:23 +03:00
Diego Paiva
941feda305 Fix kruskal's exception message for directed graph (#138) 2018-08-06 16:26:22 +03:00
Oleksii Trekhleb
88bbfdc470 Add fromArray() methods to LinkedList and DoublyLinkedList. 2018-08-06 16:12:31 +03:00
Simon
0ea24230d4 Patch 5 (#127)
* New function 'fromArray'

Function get array of Doubly Linked List Nodes, go through and append to currently list.

* New Test for new function 'fromArray'

* Minor changes

Minor changes about coding style.
2018-08-06 16:02:46 +03:00
Oleksii Trekhleb
7a4b829abe Fix issue #132 - Wrong Red-Black Tree pictures in README. 2018-08-02 16:43:54 +03:00
Oleksii Trekhleb
ecc8c65466 Add comments to Linked List code. 2018-07-30 15:38:04 +03:00
Oleksii Trekhleb
97926b1243 Add comments to Linked List code. 2018-07-30 15:35:28 +03:00
seIncorp
5105898aa7 Twice defined (#124)
* Twice defined

Parameter 'deletedTail' were defined twice.

* Update LinkedList.js

* Update LinkedList.js
2018-07-30 15:33:17 +03:00
Oleksii Trekhleb
6e897a0a7a Minor README updates. 2018-07-30 14:18:56 +03:00
Bruce-Feldman
c4605ea13d Refactor Rabin-Karp (#110)
* Simplify Rabin-Karp functionality

* Created Rabin Fingerprinting module within util directory

* Updated Rabin-Karp search to use rolling hash module
Incorporate tests from @dubzzz
2018-07-30 12:20:40 +03:00
Oleksii Trekhleb
305e30357c Add comments to HashTable hash function. 2018-07-29 08:28:03 +03:00
Oleksii Trekhleb
f1152bf4b4 Update README for Trapping Rain Water problem. 2018-07-27 14:11:33 +03:00
Oleksii Trekhleb
26239f9a97 Refactor dynamic programming approach of Trapping Rain Water problem. 2018-07-27 14:06:58 +03:00
Oleksii Trekhleb
f07e96ec59 Refactor dynamic programming approach of Trapping Rain Water problem. 2018-07-27 14:04:37 +03:00
Oleksii Trekhleb
340a71b7d9 Add brute force solution of Rain Terraces problem. 2018-07-27 13:40:07 +03:00
Oleksii Trekhleb
6fc429975f Add Rain Terraces problem. 2018-07-27 13:00:24 +03:00
Oleksii Trekhleb
3271ee92b9 Add Rain Terraces problem. 2018-07-27 12:59:56 +03:00
Keoni Garner
f142ca00b2 Add rain-terraces (trapping rain water) algorithm (#112)
* Add rain-terraces (trapping rain water) algorithm

* Fixed linting errors

* Fixed linting errors
2018-07-27 12:25:15 +03:00
Oleksii Trekhleb
80e3216609 Add annotations to Trie. 2018-07-26 18:02:34 +03:00
Oleksii Trekhleb
39acb2b65d Avoid using toBeTruthy() and toBeFalsy() because of type coercion. 2018-07-26 16:14:26 +03:00
Oleksii Trekhleb
39014f7543 Fix issue #105. 2018-07-24 12:37:55 +03:00
Oleksii Trekhleb
12f0b331b8 Add more tests for rabinKarp. 2018-07-24 12:29:12 +03:00
Nicolas DUBIEN
0361fe5cf8 Fix knuthMorrisPratt for empty word request (#101) 2018-07-24 12:26:22 +03:00
Oleksii Trekhleb
6a3a4b8697 Add new test cases for KMP algorithm. 2018-07-23 18:00:54 +03:00
Oleksii Trekhleb
76c172b20b Code style fixes for negative Counting Sort testing. 2018-07-22 18:23:39 +03:00
Nicolas DUBIEN
3be02b5519 Fix CountingSort for negative numbers (#100) 2018-07-22 18:03:13 +03:00
Oleksii Trekhleb
149444b47c Add Interpolation Search. 2018-07-18 14:35:02 +03:00
Oleksii Trekhleb
31344fa6a2 Add tests for Jump Search. 2018-07-18 12:03:21 +03:00
Oleksii Trekhleb
a327b68a06 Add Jump Search algorithm. 2018-07-18 09:21:20 +03:00
Oleksii Trekhleb
b73ddec94d Add Pascal's Triangle based solution for Unique Paths problem. 2018-07-14 11:08:19 +03:00
Oleksii Trekhleb
d8fb6579b1 Add Unique Paths problem with backtracking and DP solutions. 2018-07-14 10:35:35 +03:00
Oleksii Trekhleb
863dbdbac3 Fix issue #98. 2018-07-13 17:48:27 +03:00
Oleksii Trekhleb
fafa52c26e Refactor Floyd-Warshall tests. 2018-07-13 17:36:39 +03:00
Oleksii Trekhleb
2874637d40 Refactor Floyd-Warshall tests. 2018-07-13 17:05:21 +03:00
Oleksii Trekhleb
dca7f6f874 Refactor Floyd-Warshall. 2018-07-13 16:56:33 +03:00
Oleksii Trekhleb
994ac2781a Update Floyd-Warshall READMEs. 2018-07-13 15:02:58 +03:00
vivaxy
9f8fd33202 feat(algorithms): Add Floyd-Warshall (#97) 2018-07-13 14:23:47 +03:00
Oleksii Trekhleb
3e8540beac Add Jump Game. 2018-07-10 08:17:52 +03:00
Oleksii Trekhleb
549759757d Add bottom-up dynamic programming solution to Jump Game. 2018-07-10 07:56:28 +03:00
Oleksii Trekhleb
57c2a334ce Add top-down dynamic programming solution to Jump Game. 2018-07-10 07:37:29 +03:00
Oleksii Trekhleb
b71a2ebe9e Change naming for Jump Game files. 2018-07-10 07:23:25 +03:00
Oleksii Trekhleb
df17e29fb7 Add backtracking solution to JumpGame. 2018-07-10 07:15:36 +03:00
Oleksii Trekhleb
aacd7795d6 Add greedy solution for Jump Game. 2018-07-09 18:00:09 +03:00
Oleksii Trekhleb
e47ca45b7a Add greedy solution for Jump Game. 2018-07-09 17:59:36 +03:00
Oleksii Trekhleb
afbdb89101 Update heap documentation. 2018-07-08 04:29:12 +03:00
Correy Lim
a3d099003d Improve data-structures/heap/README.md (#94)
* Update data-structure/heap/README.md

The overuse of parenthesis in the previous description made the
explanation of a heap more diffcult to read. Following technical
writing standards, the topic of the sentence should be at the
forefront of a sentence, to give the reader an idea of what is
going to be explained in said sentence.

The mention of min heap and max heap were previously in parenthesis, in
the middle of the sentence. This change informs the reader that there
are two types of heaps, with a preface indicating which one is being
explained.

* Add min heap picture and move max heap picture

Add a picture of a min heap below the explanation of a min heap.
Move the picture of a max heap below the explanation of a max heap.

* Italicize heap terminology

Italicize the terms 'max heap' and 'min heap' to make it clear to readers that new terminology is being introduced
2018-07-08 04:27:06 +03:00
Oleksii Trekhleb
b87839062a Add Pascal's triangle. 2018-07-07 11:11:20 +03:00
Oleksii Trekhleb
f3189cca43 Add Pascal's triangle. 2018-07-07 10:35:37 +03:00
Oleksii Trekhleb
bb86b30dda Code style fixes for matrix rotation algorithm. 2018-07-06 12:02:42 +03:00
Oleksii Trekhleb
57378c5e19 Update matrix rotation README. 2018-07-06 11:52:34 +03:00
Oleksii Trekhleb
75133592bb Add square matrix rotation in-place algorithm. 2018-07-06 08:15:56 +03:00
Oleksii Trekhleb
17ad4dc4d1 Upgrade packages. 2018-07-05 16:30:00 +03:00
Oleksii Trekhleb
d0499d2544 Minor code style fixes for DoublyLinkedList. 2018-07-05 15:44:25 +03:00
Oleksii Trekhleb
a72fda4dfd Minor code style fixes for DoublyLinkedList. 2018-07-05 15:33:39 +03:00
Oleksii Trekhleb
6a5ed26bd2 Extend DoublyLinkedListNode tests. 2018-07-05 15:28:11 +03:00
Oleksii Trekhleb
a9eeea2ca8 Update doubly linked list README. 2018-07-05 15:25:51 +03:00
Huzaima Khan
6b354ad4ce Added doubly linked list (#92)
* Added doubly linked list

* improved doubly linked list coverage
2018-07-05 15:18:57 +03:00
Oleksii Trekhleb
fef2aa7691 Update README. 2018-07-04 18:09:55 +03:00
Bruce-Feldman
e36c441fa9 Minor fixes. (#91)
* Get Bit: Make more terse

* Power of two: Allowed 1 as a valid power of 2.
Power of two: Removed unnecessary exception throwing.

* Fisher Yates: Made more terse

* Least Common Multiple: Fill undefined value

* Greatest Common Divisor: Fill undefined value.
Greatest Common Divisor: Make more terse.
2018-07-04 17:53:22 +03:00
Oleksii Trekhleb
93bfe97e27 Add test cases for sorting negative numbers and zeros. 2018-07-03 12:06:00 +03:00
m-maksyutin
d82958dea9 Fix the insertion sort (#86)
* Fix LinkedList

* Fix the prepend method for the LinkedList

* Fix the remove method for the MinHeap

* Correct a comment

* Fix BST removal method

* Fix the findEdge method of the graph

* Fix the value returned by DisjointSet union

* Add recursive factorial function

* Fix the insertion sort
2018-07-03 11:56:34 +03:00
Oleksii Trekhleb
e3b482c5e6 Update bloom filters description. 2018-06-30 21:48:57 +03:00
Oleksii Trekhleb
a2310c59d3 Delete false positive tests for bloom filter. 2018-06-30 20:46:34 +03:00
Oleksii Trekhleb
610b120e27 BloomFilter minor fixes. 2018-06-30 20:39:46 +03:00
Oleksii Trekhleb
b33b1fe1bc Update bloom filter README. 2018-06-30 20:23:02 +03:00
arnav-aggarwal
41a6430532 Add bloom filter (#84) 2018-06-30 20:07:19 +03:00
Oleksii Trekhleb
b33f1d52dc Add "Combination Sum" backtracking algorithm. 2018-06-30 10:19:14 +03:00
Oleksii Trekhleb
b41cffea0f Add permutations/combinations cheat sheets. 2018-06-29 14:44:11 +03:00
Oleksii Trekhleb
00f75028bf Simplify permutateWithoutRepetitions algorithm. 2018-06-29 12:23:26 +03:00
Oleksii Trekhleb
db7ab9e299 Simplify permutateWithRepetitions algorithm. 2018-06-28 21:28:50 +03:00
m-maksyutin
c5ed81d85e Add recursive factorial function (#85)
* Fix LinkedList

* Fix the prepend method for the LinkedList

* Fix the remove method for the MinHeap

* Correct a comment

* Fix BST removal method

* Fix the findEdge method of the graph

* Fix the value returned by DisjointSet union

* Add recursive factorial function
2018-06-28 21:03:31 +03:00
Oleksii Trekhleb
65f08db5de Simplify combineWithRepetitions function. 2018-06-28 14:05:58 +03:00
Oleksii Trekhleb
e5a06e654b Simplify combineWithoutRepetitions function. 2018-06-28 13:46:26 +03:00
Oleksii Trekhleb
55ecc0b313 Fix typo. 2018-06-27 18:59:25 +03:00
Oleksii Trekhleb
933848b215 Add more bit manipulation functions. 2018-06-27 18:05:18 +03:00
Oleksii Trekhleb
c268203259 Add more bit manipulation functions. 2018-06-27 17:33:16 +03:00
Oleksii Trekhleb
792f4906df Add bit manipulation section. 2018-06-27 17:19:20 +03:00
m-maksyutin
36e0bfeb32 Fix the value returned by DisjointSet union (#81)
* Fix LinkedList

* Fix the prepend method for the LinkedList

* Fix the remove method for the MinHeap

* Correct a comment

* Fix BST removal method

* Fix the findEdge method of the graph

* Fix the value returned by DisjointSet union
2018-06-27 16:22:54 +03:00
Oleksii Trekhleb
d69199e658 Add regular expression matching algorithm. 2018-06-25 20:02:24 +03:00
Oleksii Trekhleb
c96bbdf00e Code style fix. 2018-06-25 14:34:40 +03:00
m-maksyutin
88d038b5c8 Fix the findEdge method of the graph (#80)
* Fix LinkedList

* Fix the prepend method for the LinkedList

* Fix the remove method for the MinHeap

* Correct a comment

* Fix BST removal method

* Fix the findEdge method of the graph
2018-06-25 14:33:31 +03:00
Oleksii Trekhleb
89fb0e6239 Add Levenshtein Distance algorithm explanations. 2018-06-23 20:59:59 +03:00
Oleksii Trekhleb
a9502851f5 Update READMEs. 2018-06-23 13:21:07 +03:00
Oleksii Trekhleb
619c58ec87 Update READMEs. 2018-06-22 15:34:32 +03:00
Oleksii Trekhleb
b65a992452 Update READMEs. 2018-06-22 15:04:28 +03:00
Amjad Ali
e53f5f909d Added Complexity of Each Algorithm in Sorting/ directory. (#76)
* Added Complexity to Bubble Sort README.md

* Added Complexity to Counting-Sort README.md

* Italicized n in Bubble Sort README.md

* Added Complexity to Heap Sort README.md

* Added Complexity to Insertion Sort README.md

* Added Complexity to Merge Sort README.md

* Added Complexity to Quick Sort README.md

* Added Complexity to Radix Sort README.md

* Added Complexity to Selection Sort README.md

* Added Complexity to SHell Sort README.md
2018-06-22 14:54:40 +03:00
Oleksii Trekhleb
831ce89a45 Update README for integer partition. 2018-06-22 14:50:38 +03:00
Nnadozie Okeke
16b6ea506a Corrected explanations and included an example (#75) 2018-06-22 14:31:57 +03:00
Oleksii Trekhleb
2334583635 Add setValue and nodeCopy methods to binary tree node. 2018-06-22 08:22:12 +03:00
m-maksyutin
bd5a16be71 Fix BST removal method (#74)
* Fix LinkedList

* Fix the prepend method for the LinkedList

* Fix the remove method for the MinHeap

* Correct a comment

* Fix BST removal method
2018-06-22 07:57:52 +03:00
Oleksii Trekhleb
e558231474 Add comments. 2018-06-21 17:59:31 +03:00
Oleksii Trekhleb
81d17bc4f9 Add comments. 2018-06-21 17:48:35 +03:00
Oleksii Trekhleb
5bdcbb397d Code style fixes. 2018-06-21 16:59:20 +03:00
hariv
9e210ae560 Z algorithm implementation (#77)
* Implemented Z algorithm

* Fixed bugs in implementation and added tests

* Added README explaining z algorithm
2018-06-21 16:42:13 +03:00
m-maksyutin
9311735867 Correct a comment (#66)
* Fix LinkedList

* Fix the prepend method for the LinkedList

* Fix the remove method for the MinHeap

* Correct a comment
2018-06-18 16:30:30 +03:00
Oleksii Trekhleb
98092ee43f Code style fixes. 2018-06-18 15:57:45 +03:00
Sina Sharafzadeh
8c206a9976 fix unbound knapsack problem with items more than 1(default value) (#73) 2018-06-18 15:50:02 +03:00
Oleksii Trekhleb
d154015cda Code style fixes. 2018-06-14 07:59:47 +03:00
Oleksii Trekhleb
19f4cc70d3 Add recursive way of generating permutations with repetitions. 2018-06-13 08:15:21 +03:00
Matt Mapplebeck
b0c55ec817 add recursive solution to permutations with repetitions problem (#52)
* add recursive solution to permutations with repetitions problem

* fix untested function, failing test

* add comments
2018-06-13 08:03:56 +03:00
Oleksii Trekhleb
8d3f83cfb7 Simplify combineWithoutRepetition algorithm. 2018-06-13 07:21:57 +03:00
Oleksii Trekhleb
c3a961840d Fix BST removal method. 2018-06-13 06:39:18 +03:00
Felix Rilling
5734e0a43e Fix typos (#59)
* Fixed typo in the word 'independant'

* Fixed typo in the word 'subsequnce'

* Fixed typo in the word 'icecream'

* Fixed typo in the word 'subsequnce' in shortestCommonSubsequence

* Fixed typo in the word 'depected'

* Fixed typo in the word 'paramaters'
2018-06-12 17:46:40 +03:00
Oleksii Trekhleb
c536aa2c51 Refactor liuHui. 2018-06-12 17:29:57 +03:00
Oleksii Trekhleb
1e2fdc6943 Refactor README. 2018-06-12 15:32:56 +03:00
mantou
7dc9b80f62 feat: Add Liu Hui's π algorithm (#61) 2018-06-12 14:54:00 +03:00
Oleksii Trekhleb
9de6bc7de3 Add more tests. 2018-06-08 16:54:07 +03:00
Oleksii Trekhleb
5ac85a230c Update READMEs. 2018-06-08 15:38:36 +03:00
Oleksii Trekhleb
294bd2acb7 Update READMEs. 2018-06-06 07:54:38 +03:00
Oleksii Trekhleb
00fbba5438 Update tests. 2018-06-06 07:49:12 +03:00
Oleksii Trekhleb
183dade079 Update Fenwick Tree readme and do code style fixes. 2018-06-06 07:41:28 +03:00
Christopher Samuel
1a4fe11a80 Added Binary Indexed Tree / Fenwick Tree Implementation (#51)
* added fenwick tree implementation

* added fenwick tree implementation
2018-06-06 06:25:31 +03:00
Oleksii Trekhleb
a1060c2a94 Merge branch 'master' of https://github.com/trekhleb/javascript-algorithms 2018-06-05 21:50:44 +03:00
Oleksii Trekhleb
6c892c4b2f Fix bug with primality test. 2018-06-05 21:50:08 +03:00
m-maksyutin
38688f25c5 Fix the remove method for the MinHeap (#50)
* Fix LinkedList

* Fix the prepend method for the LinkedList

* Fix the remove method for the MinHeap
2018-06-05 16:17:14 +03:00
Oleksii Trekhleb
9f83862212 Update README for segment tree. 2018-06-05 08:47:52 +03:00
Oleksii Trekhleb
434a5649cb Refactor segment tree implementation. 2018-06-05 08:45:00 +03:00
Oleksii Trekhleb
5784a4a95b Merge branch 'master' into segment-tree 2018-06-05 06:12:30 +03:00
Oleksii Trekhleb
74b93d36cb Add isPowerOfTwo functions. 2018-06-04 20:42:22 +03:00
Oleksii Trekhleb
c7610d58b1 Update README. 2018-06-04 06:57:33 +03:00
Vignesh Manoharan
2e5fd8d583 Segment Tree implementation (#45)
* added segment tree implementation - supports custom operation

* added readme for segment tree
2018-06-04 06:32:34 +03:00
m-maksyutin
beb8501aca Fix the prepend method for the LinkedList (#47)
* Fix LinkedList

* Fix the prepend method for the LinkedList
2018-06-04 05:21:42 +03:00
Oleksii Trekhleb
91d4714d19 Code styling fixes for Sieve of Eratosthenes. 2018-06-03 09:34:48 +03:00
Juan Pablo Valencia
943f83492a Adding Sieve of Eratosthenes (#46)
* Adding Sieve of Eratosthenes

* Typo
2018-06-03 09:25:15 +03:00
Oleksii Trekhleb
d2b8eabcf4 Update READMEs. 2018-06-02 22:21:59 +03:00
Oleksii Trekhleb
90b56bc3d3 Fix issue #37 with AVL tree. 2018-06-02 22:11:01 +03:00
Oleksii Trekhleb
924066bb0c Do minor optimisations to factorial function. 2018-06-02 09:40:32 +03:00
Oleksii Trekhleb
88bd8d7044 Add JSdocs for fibonacci. 2018-06-02 09:32:50 +03:00
Oliver Hepworth-Bell
d267d72524 Added fibonacci sequence as well as fibonacci nth, renamed functions accordingly (#36) 2018-06-02 09:31:09 +03:00
m-maksyutin
a63bc67cf4 Fix LinkedList (#42) 2018-06-02 09:23:55 +03:00
Oleksii Trekhleb
0edb1525ea Throw error on remove from red-black tree. 2018-06-02 08:51:45 +03:00
Oleksii Trekhleb
26d6b7877d Improve test-coverage for red-black tree. 2018-06-02 08:24:31 +03:00
Oleksii Trekhleb
19789c6a94 Add red-black tree. 2018-06-02 08:15:40 +03:00
Oleksii Trekhleb
48f7ea1ad5 Add one more test for BST. 2018-06-01 10:52:23 +03:00
Oleksii Trekhleb
4132522d4a Set up node comparator for BST. 2018-06-01 08:28:36 +03:00
Oleksii Trekhleb
02299b77e6 Add uncle property to binary tree node. 2018-06-01 05:16:07 +03:00
Oleksii Trekhleb
e6de25ecb3 Use HashTable in TrieNode. 2018-05-31 21:37:13 +03:00
Oleksii Trekhleb
5b3de38cca Update hash table methods. 2018-05-31 21:35:53 +03:00