├── .github ├── code-of-conduct.md ├── contributing.md ├── dependabot.yml ├── issue-template.md └── pull-request-template.md ├── .gitignore ├── docs ├── 2-sum.md ├── 2d-line-intersection.md ├── 2d-separating-axis-test.md ├── a-star.md ├── activity-selection.md ├── add-polynomials.md ├── adding-using-bits.md ├── adjacency-lists-graphs-representation.md ├── affine-cipher.md ├── aho-corasick-algorithm.md ├── algorithm-x.md ├── amicable-numbers.md ├── anagram-search.md ├── area-of-polygon.md ├── area-of-triangle.md ├── arithmetic-on-large-numbers.md ├── armstrong-numbers.md ├── array-median.md ├── artificial-neutral-network.md ├── atbash-cipher.md ├── autokey-cipher.md ├── automorphic-numbers.md ├── average-stream-numbers.md ├── average.md ├── axis-aligned-bounding-box-collision.md ├── babylonian-method.md ├── baconian-cipher.md ├── bag.md ├── bead-sort.md ├── biggest-of-n-numbers.md ├── biggest-suffix.md ├── binary-search.md ├── binomial-coefficient.md ├── bipartite-check.md ├── birthday-paradox.md ├── bit-divisor.md ├── bogo-sort.md ├── boyer-moore-algorithm.md ├── bresenham-line.md ├── brians-brain.md ├── bubble-sort.md ├── bucket-sort.md ├── byte-swapper.md ├── caesar-cipher.md ├── catalan-number.md ├── chans-algorithm.md ├── check-is-square.md ├── circle-sort.md ├── closest-pair-of-point.md ├── code-chef.md ├── code-eval.md ├── coderbyte.md ├── cohen-sutherland-lineclip.md ├── colummnar-cipher.md ├── comb-sort.md ├── convert-numbers-to-binary.md ├── convolution.md ├── convolutional-neutral-network.md ├── conways-game-of-life.md ├── coprime-numbers.md ├── count-digits.md ├── count-set-bits.md ├── count-trailing-zeroes.md ├── counting-sort.md ├── crossword-puzzle.md ├── cycle-sort.md ├── dbscan.md ├── decision-tree.md ├── decoding-of-string.md ├── delannoy-number.md ├── derangements.md ├── determine-endianess.md ├── dfa-division.md ├── dijkstra-shortest-path.md ├── diophantine.md ├── distance-between-points.md ├── divided-differences.md ├── egyptian-fraction.md ├── elementary-cellular-automata.md ├── euler-totient.md ├── exponential-search.md ├── exponentiation-power.md ├── factorial.md ├── factorization-machines.md ├── fast-fourier-transform.md ├── fast-inverse-square-root.md ├── fibonacci-search.md ├── fifteen-puzzle.md ├── finite-automata.md ├── flash-sort.md ├── flip-bits.md ├── fuzzy-search.md ├── gaussian-mixtrue-model.md ├── generic-algorithm.md ├── gnome-sort.md ├── gradient-boostring-trees.md ├── graham-scan.md ├── grundy-numbers-kayle-game.md ├── hackerearth.md ├── hackerrank.md ├── halfplane-intersection.md ├── hamming-distace.md ├── hashes.md ├── heap-sort.md ├── hierachical-clustering.md ├── image-processing.md ├── insertion-sort.md ├── integral.md ├── interpolation-search.md ├── intro-sort.md ├── inversion-count.md ├── invert-bit.md ├── isodata.md ├── jaccard-similarity.md ├── jarvis-march.md ├── jose-phus-problem.md ├── jump-search.md ├── k-means.md ├── k-nearest-neighbors.md ├── karatsuba-multiplication.md ├── karger-minimum-cut-algorithm.md ├── kasai-algorithm.md ├── kmp-algorithm.md ├── knight-tour.md ├── kth-smallest-element-algorithm.md ├── langtons-ant.md ├── lapindrom-checker.md ├── leap-year.md ├── leetcode.md ├── levenshtein-distance.md ├── linear-regression.md ├── linear-search.md ├── linked-list.md ├── lipogram-checker.md ├── list.md ├── logistic-regression.md ├── lonely-integer.md ├── m-coloring-problem.md ├── magic-number.md ├── magic-square.md ├── majority-element.md ├── maximum-contiguous-subsequence-sum.md ├── maximun-xor-value.md ├── median-of-medians.md ├── median-sort.md ├── merge-sort-using-divide-and-conquer.md ├── merge-sort.md ├── minimax.md ├── minimum-subarray-size-with-degree.md ├── monte-carlo.md ├── n-queen.md ├── native-bayes.md ├── nearest-sequence-memory.md ├── neutral-network.md ├── neutral-style-transfer.md ├── nim-next-best-move-game.md ├── nim-win-loss-game.md ├── no-operator-addition.md ├── nobili-cellular-automata.md ├── number-of-ways-in-maze.md ├── optima-binary-search-tree.md ├── packet-sniffer.md ├── paint-fill.md ├── partitions-of-set.md ├── perceptron.md ├── permutation-of-strings.md ├── pigeonhole-sort.md ├── power-of-2.md ├── powerset.md ├── principal-component-analysis.md ├── project-euler.md ├── q-learning.md ├── queue.md ├── quick-select.md ├── quick-sort-using-divide-and-conquer.md ├── quick-sort.md ├── quickhull.md ├── radix-sort.md ├── random-forest.md ├── random-from-stream.md ├── random-node-linked-list.md ├── randomized-quicksort.md ├── rat-in-maze.md ├── reservoir-sampling.md ├── restricted-boltzman-machine.md ├── rosalind.md ├── runge-kutt.md ├── sat.md ├── selection-sort.md ├── shaker-sort.md ├── shell-sort.md ├── shuffle-an-array.md ├── sleep-sort.md ├── sphere-tetrahedron-intersection.md ├── split-list.md ├── spoj.md ├── stack.md ├── stooge-sort.md ├── strassen-matrix-manipulation.md ├── subset-generation.md ├── subset-sum.md ├── sudoku-solve.md ├── sum-binary-numbers.md ├── sum-equals-xor.md ├── sutherland-hodgman-clipping.md ├── ternay-search.md ├── thrice-unique-number.md ├── tokenizer.md ├── top-coder.md ├── topological-sort.md ├── tournament-method-to-find-min-max.md ├── tree-sort.md ├── tree.md ├── tsp.md ├── twice-unique-number.md ├── unique-number.md ├── validate-ip.md ├── vigenere-cipher.md ├── von-neoumann-cellular-automata.md ├── warnock-algorithm.md ├── x-power-y.md └── xor-swap.md ├── license ├── netlify.toml ├── package.json ├── readme.md ├── repos.json ├── scripts ├── change.js ├── create.sh ├── docker-yarn-start.sh ├── generate-docs.js ├── git-add.js ├── git-clone.js ├── git-commit.js ├── git-pull.js ├── git-push.js └── repos.js ├── templates ├── code-of-conduct.txt ├── contributing.txt ├── issue-template.txt ├── license.txt ├── pull-request-template.txt └── readme.txt └── website ├── blog └── 2019-02-19-new-website.md ├── core └── Footer.js ├── data ├── algorithms.js ├── community.js ├── languages.js ├── libraries.js └── repos.js ├── package.json ├── pages └── en │ ├── categories.js │ ├── help.js │ ├── index.js │ └── libraries.js ├── readme.md ├── sidebars.json ├── siteConfig.js └── static ├── css └── custom.css └── img ├── algorithms-white.png ├── algorithms-white.svg ├── algorithms.png ├── algorithms.svg ├── allalgorithms-white.png ├── screenshot-2019-may-6.png └── tryhtml.png /.github/code-of-conduct.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Attribution 36 | 37 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 38 | 39 | [homepage]: http://contributor-covenant.org 40 | [version]: http://contributor-covenant.org/version/1/4/ 41 | -------------------------------------------------------------------------------- /.github/contributing.md: -------------------------------------------------------------------------------- 1 | ## Contributing 2 | 3 | > Please note that this project is released with a [Contributor Code of Conduct](code-of-conduct.md). By participating in this project you agree to abide by its terms. -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: npm 4 | directory: "/" 5 | schedule: 6 | interval: "daily" 7 | -------------------------------------------------------------------------------- /.github/issue-template.md: -------------------------------------------------------------------------------- 1 | I am creating an issue because... 2 | -------------------------------------------------------------------------------- /.github/pull-request-template.md: -------------------------------------------------------------------------------- 1 | I am creating a pull request for... 2 | 3 | - [ ] New algorithm 4 | - [ ] Update to an algorithm 5 | - [ ] Fix an error 6 | - [ ] Other - *Describe below* -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | 3 | projects 4 | node_modules 5 | 6 | lib/core/metadata.js 7 | lib/core/MetadataBlog.js 8 | 9 | website/translated_docs 10 | website/build/ 11 | website/node_modules 12 | website/i18n/* 13 | 14 | *lock -------------------------------------------------------------------------------- /docs/2-sum.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: 2-sum 3 | title: 2 sum 4 | sidebar_label: 2 sum 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/2-sum.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/2d-line-intersection.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: 2d-line-intersection 3 | title: 2d line intersection 4 | sidebar_label: 2d line intersection 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/2d-line-intersection.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/2d-separating-axis-test.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: 2d-separating-axis-test 3 | title: 2d separating axis test 4 | sidebar_label: 2d separating axis test 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/2d-separating-axis-test.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/a-star.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: a-star 3 | title: A star 4 | sidebar_label: A star 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/a-star.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/activity-selection.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: activity-selection 3 | title: Activity selection 4 | sidebar_label: Activity selection 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/activity-selection.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/add-polynomials.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: add-polynomials 3 | title: Add polynomials 4 | sidebar_label: Add polynomials 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/add-polynomials.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/adding-using-bits.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: adding-using-bits 3 | title: Adding using bits 4 | sidebar_label: Adding using bits 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/adding-using-bits.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/adjacency-lists-graphs-representation.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: adjacency-lists-graphs-representation 3 | title: Adjacency lists graphs representation 4 | sidebar_label: Adjacency lists graphs representation 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/adjacency-lists-graphs-representation.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/affine-cipher.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: affine-cipher 3 | title: Affine cipher 4 | sidebar_label: Affine cipher 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/affine-cipher.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/aho-corasick-algorithm.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: aho-corasick-algorithm 3 | title: Aho-Corasick algorithm 4 | sidebar_label: Aho-Corasick algorithm 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/aho-corasick-algorithm.md) to add the content for this algorithm. 8 | -------------------------------------------------------------------------------- /docs/algorithm-x.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: algorithm-x 3 | title: Algorithm x 4 | sidebar_label: Algorithm x 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/algorithm-x.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/amicable-numbers.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: amicable-numbers 3 | title: Amicable numbers 4 | sidebar_label: Amicable numbers 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/amicable-numbers.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/anagram-search.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: anagram-search 3 | title: Anagram search 4 | sidebar_label: Anagram search 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/anagram-search.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/area-of-polygon.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: area-of-polygon 3 | title: Area of polygon 4 | sidebar_label: Area of polygon 5 | --- 6 | 7 | A polygon is a closed sequence of segments in the plane. It is often 8 | convenient to represent it as a sequence of vertices *P1, 9 | P2, ..., Pn*, with the convention that any pair of 10 | adjacent vertices in the sequence define a segment in the polygon, and 11 | that the first and last vertices are the same. Each point *Pi* 12 | is assumed to have coordinates in the plane *(xi, 13 | yi)*. 14 | 15 | ## Simple polygons 16 | 17 | A [simple polygon][] is a non-self-intersecting one, i.e. no pair of 18 | segments intersects each other. 19 | 20 | ### Formula 21 | 22 | The *signed* area of the polygon is given by the following formula: 23 | 24 | area of a polygon 27 | 28 | The area is *signed* because going in reverse order means having a result 29 | with the opposite sign. To get the area it's necessary to take the 30 | absolute value. 31 | 32 | ### Algorithm 33 | 34 | The following algorithm translates the formula in pseudocode: 35 | 36 | ``` 37 | /* 38 | Vs is an array of vertices. Each vertex is supposed to be 39 | an array itself, with X values in index 0 and Y values in 40 | index 1. It is also assumed that the last element in Vs is 41 | the same as the first one. 42 | */ 43 | polygon_area_simple (Vs) { 44 | N = Vs.size; # number of elements in Vs 45 | sum = 0; 46 | for i in 0 .. (N - 1): 47 | sum = sum + Vs[i][0] * Vs[i+1][1] - Vs[i+1][0] * Vs[i][1]; 48 | return abs(sum) / 2; 49 | } 50 | ``` 51 | 52 | ## Performance 53 | 54 | The algorithm for [simple polygons][simple polygon] is linear with respect 55 | to the number of vertices (O(N)). 56 | 57 | ## Implementation 58 | 59 | | | Language | Link | 60 | |:-: | :-: | :-: | 61 | | | | | 62 | 63 | ## Helpful links 64 | 65 | - [Polygon][] 66 | 67 | 68 | [simple polygon]: https://en.wikipedia.org/wiki/Simple_polygon 69 | [Polygon]: https://en.wikipedia.org/wiki/Polygon 70 | -------------------------------------------------------------------------------- /docs/area-of-triangle.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: area-of-triangle 3 | title: Area of triangle 4 | sidebar_label: Area of triangle 5 | --- 6 | 7 | A *triangle* is a polygon with three sides and three vertices. 8 | Calculating its area efficiently depends on what is known about it. 9 | 10 | ## From base and height 11 | 12 | The basic formula assumes knowledge of the length of one of the sides 13 | (called *base*) and the length of the *height* of the triangle with 14 | respect to that side. This *height* is the segment that originates from 15 | the vertex that is *not* on the side we know about, and intersects the 16 | side we know about at a right angle. 17 | 18 | Assuming the base is put horizontally and the third vertex above it, the 19 | following picture results. Quantity *b* is the length of the bottom 20 | side, and *h* the height with respect to it. 21 | 22 | Triangle 25 | 26 | Height can sometimes be referred to as *altitude*. 27 | 28 | ### Formula 29 | 30 | In this case, the area is calculated as follows: 31 | 32 | T=\frac{b \cdot h}{2} 35 | 36 | 37 | ### Algorithm 38 | 39 | The algorithm can be derived directly from the defining formula above: 40 | 41 | ``` 42 | triangle_area_basic (b, h) { 43 | return b * h / 2; 44 | } 45 | ``` 46 | 47 | ## In the euclidean plane 48 | 49 | In this section, it is assumed that the triangle is known by the 50 | coordinates of its three vertices A, B, and C on the plane: 51 | 52 | A, B, and C in the plane 53 | 54 | ### Formula 55 | 56 | In this case, the area of the triangle can be calculated as follows: 57 | 58 | T = \frac{|(x_B - x_A)(y_C - y_A) - (x_C - x_A)(y_B - y_A)|}{2} 59 | 60 | ### Algorithm 61 | 62 | The following algorithm is a direct translation of the formula: 63 | 64 | ``` 65 | triangle_area_plane (x_A, y_A, x_B, y_B, x_C, y_C) { 66 | return abs((x_B - x_A) * (y_C - y_A) - (x_C - x_A) * (y_B - y_A)) / 2; 67 | } 68 | ``` 69 | 70 | ## In the euclidean space 71 | 72 | In this section, it is assumed that the triangle is known by the 73 | coordinates of its three vertices A, B, and C in the three-dimensional 74 | space: 75 | 76 | 77 | 78 | ### Formula 79 | 80 | The formula to calculate the area involves calculating the determinant 81 | of three matrices: 82 | 83 | triangle area in the plane 84 | 85 | The absolute value of each determinant is the double of the area of the 86 | triangle obtained by projecting the target triangle onto one of the 87 | coordinate planes, which allows reusing the formula for the triangle in 88 | the plane in a previous section. 89 | 90 | ### Algorithm 91 | 92 | The following algorithm leverages the triangle area calculation in the 93 | plane, described in a previous section and not repeated here: 94 | 95 | ``` 96 | /* Assume that A, B, and C are 3-dimensional arrays 97 | X at index 0, Y at index 1, Z at index 2 */ 98 | triangle_area_space (A, B, C) { 99 | x = triangle_area_plane(A[1], A[2], B[1], B[2], C[1], C[2]); 100 | y = triangle_area_plane(A[2], A[0], B[2], B[0], C[2], C[0]); 101 | z = triangle_area_plane(A[0], A[1], B[0], B[1], C[0], C[1]); 102 | return sqrt(x * x + y * y + z * z); 103 | } 104 | ``` 105 | 106 | *Note*: the division by two in the formula is already included in the 107 | result from the calculation of the area in the plane. 108 | 109 | ## Performance 110 | 111 | All algorithms for calculating the area of a triangle in the sections 112 | above execute in constant time (O(0)). 113 | 114 | ## Implementations 115 | 116 | | | Language | Link | 117 | |:-: | :-: | :-: | 118 | | | | | 119 | 120 | ## Helpful Links 121 | 122 | - [Triangle][] 123 | - [Area of Triangles and Polygons][] 124 | 125 | [Triangle]: https://en.wikipedia.org/wiki/Triangle 126 | [Area of Triangles and Polygons]: http://geomalgorithms.com/a01-_area.html 127 | -------------------------------------------------------------------------------- /docs/arithmetic-on-large-numbers.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: arithmetic-on-large-numbers 3 | title: Arithmetic on large numbers 4 | sidebar_label: Arithmetic on large numbers 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/arithmetic-on-large-numbers.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/armstrong-numbers.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: armstrong-numbers 3 | title: Armstrong numbers 4 | sidebar_label: Armstrong numbers 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/armstrong-numbers.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/array-median.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: array-median 3 | title: Array median 4 | sidebar_label: Array median 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/array-median.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/artificial-neutral-network.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: artificial-neutral-network 3 | title: Artificial neutral network 4 | sidebar_label: Artificial neutral network 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/artificial-neutral-network.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/atbash-cipher.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: atbash-cipher 3 | title: Atbash cipher 4 | sidebar_label: Atbash cipher 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/atbash-cipher.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/autokey-cipher.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: autokey-cipher 3 | title: Autokey cipher 4 | sidebar_label: Autokey cipher 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/autokey-cipher.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/automorphic-numbers.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: automorphic-numbers 3 | title: Automorphic numbers 4 | sidebar_label: Automorphic numbers 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/automorphic-numbers.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/average-stream-numbers.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: average-stream-numbers 3 | title: Average stream numbers 4 | sidebar_label: Average stream numbers 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/average-stream-numbers.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/average.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: average 3 | title: Average 4 | sidebar_label: Average 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/average.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/axis-aligned-bounding-box-collision.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: axis-aligned-bounding-box-collision 3 | title: Axis aligned bounding box collision 4 | sidebar_label: Axis aligned bounding box collision 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/axis-aligned-bounding-box-collision.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/babylonian-method.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: babylonian-method 3 | title: Babylonian method 4 | sidebar_label: Babylonian method 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/babylonian-method.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/baconian-cipher.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: baconian-cipher 3 | title: Baconian cipher 4 | sidebar_label: Baconian cipher 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/baconian-cipher.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/bag.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: bag 3 | title: Bag 4 | sidebar_label: Bag 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/bag.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/bead-sort.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: bead-sort 3 | title: Bead sort 4 | sidebar_label: Bead sort 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/bead-sort.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/biggest-of-n-numbers.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: biggest-of-n-numbers 3 | title: Biggest of n numbers 4 | sidebar_label: Biggest of n numbers 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/biggest-of-n-numbers.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/biggest-suffix.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: biggest-suffix 3 | title: Biggest suffix 4 | sidebar_label: Biggest suffix 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/biggest-suffix.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/binary-search.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: binary-search 3 | title: Binary search 4 | sidebar_label: Binary search 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/binary-search.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/binomial-coefficient.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: binomial-coefficient 3 | title: Binomial coefficient 4 | sidebar_label: Binomial coefficient 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/binomial-coefficient.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/bipartite-check.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: bipartite-check 3 | title: Bipartite check 4 | sidebar_label: Bipartite check 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/bipartite-check.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/birthday-paradox.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: birthday-paradox 3 | title: Birthday paradox 4 | sidebar_label: Birthday paradox 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/birthday-paradox.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/bit-divisor.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: bit-divisor 3 | title: Bit divisor 4 | sidebar_label: Bit divisor 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/bit-divisor.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/bogo-sort.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: bogo-sort 3 | title: Bogo sort 4 | sidebar_label: Bogo sort 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/bogo-sort.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/boyer-moore-algorithm.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: boyer-moore-algorithm 3 | title: Boyer-Moore algorithm 4 | sidebar_label: Boyer-Moore algorithm 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/boyer-moore-algorithm.md) to add the content for this algorithm. 8 | -------------------------------------------------------------------------------- /docs/bresenham-line.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: bresenham-line 3 | title: Bresenham line 4 | sidebar_label: Bresenham line 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/bresenham-line.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/brians-brain.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: brians-brain 3 | title: Brians brain 4 | sidebar_label: Brians brain 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/brians-brain.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/bubble-sort.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: bubble-sort 3 | title: Bubble sort 4 | sidebar_label: Bubble sort 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/bubble-sort.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/bucket-sort.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: bucket-sort 3 | title: Bucket sort 4 | sidebar_label: Bucket sort 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/bucket-sort.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/byte-swapper.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: byte-swapper 3 | title: Byte swapper 4 | sidebar_label: Byte swapper 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/byte-swapper.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/caesar-cipher.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: caesar-cipher 3 | title: Caesar cipher 4 | sidebar_label: Caesar cipher 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/caesar-cipher.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/catalan-number.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: catalan-number 3 | title: Catalan number 4 | sidebar_label: Catalan number 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/catalan-number.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/chans-algorithm.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: chans-algorithm 3 | title: Chans algorithm 4 | sidebar_label: Chans algorithm 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/chans-algorithm.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/check-is-square.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: check-is-square 3 | title: Check is square 4 | sidebar_label: Check is square 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/check-is-square.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/circle-sort.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: circle-sort 3 | title: Circle sort 4 | sidebar_label: Circle sort 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/circle-sort.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/closest-pair-of-point.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: closest-pair-of-point 3 | title: Closest pair of point 4 | sidebar_label: Closest pair of point 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/closest-pair-of-point.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/code-chef.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: code-chef 3 | title: Code chef 4 | sidebar_label: Code chef 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/code-chef.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/code-eval.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: code-eval 3 | title: Code eval 4 | sidebar_label: Code eval 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/code-eval.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/coderbyte.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: coderbyte 3 | title: Coderbyte 4 | sidebar_label: Coderbyte 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/coderbyte.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/cohen-sutherland-lineclip.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: cohen-sutherland-lineclip 3 | title: Cohen-Sutherland lineclip 4 | sidebar_label: Cohen-Sutherland lineclip 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/cohen-sutherland-lineclip.md) to add the content for this algorithm. 8 | -------------------------------------------------------------------------------- /docs/colummnar-cipher.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: colummnar-cipher 3 | title: Colummnar cipher 4 | sidebar_label: Colummnar cipher 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/colummnar-cipher.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/comb-sort.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: comb-sort 3 | title: Comb sort 4 | sidebar_label: Comb sort 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/comb-sort.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/convert-numbers-to-binary.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: convert-numbers-to-binary 3 | title: Convert numbers to binary 4 | sidebar_label: Convert numbers to binary 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/convert-numbers-to-binary.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/convolution.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: convolution 3 | title: Convolution 4 | sidebar_label: Convolution 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/convolution.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/convolutional-neutral-network.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: convolutional-neutral-network 3 | title: Convolutional neutral network 4 | sidebar_label: Convolutional neutral network 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/convolutional-neutral-network.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/conways-game-of-life.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: conways-game-of-life 3 | title: Conways game of life 4 | sidebar_label: Conways game of life 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/conways-game-of-life.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/coprime-numbers.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: coprime-numbers 3 | title: Coprime numbers 4 | sidebar_label: Coprime numbers 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/coprime-numbers.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/count-digits.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: count-digits 3 | title: Count digits 4 | sidebar_label: Count digits 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/count-digits.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/count-set-bits.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: count-set-bits 3 | title: Count set bits 4 | sidebar_label: Count set bits 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/count-set-bits.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/count-trailing-zeroes.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: count-trailing-zeroes 3 | title: Count trailing zeroes 4 | sidebar_label: Count trailing zeroes 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/count-trailing-zeroes.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/counting-sort.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: counting-sort 3 | title: Counting sort 4 | sidebar_label: Counting sort 5 | --- 6 | 7 | Counting sort is an algorithm for sorting a collection of objects according to keys that are small integers; that is, it is an integer sorting algorithm. It operates by counting the number of objects that have each distinct key value, and using arithmetic on those counts to determine the positions of each key value in the output sequence. Its running time is linear in the number of items and the difference between the maximum and minimum key values, so it is only suitable for direct use in situations where the variation in keys is not significantly greater than the number of items. 8 | 9 | 10 | ## Performance 11 | 12 | | Complexity | | 13 | | -------------------------- | ----------------------------------- | 14 | | Worst-case performance | O(n + k) | 15 | | Best-case performance | O(n + k) | 16 | | Average performance | O(n + k) | 17 | | Worst-case space complexity| O(n + k) | 18 | 19 | Where n is the number of elements in input array and k is the range of input 20 | 21 | ![img](http://www-scf.usc.edu/~zhan468/public/Notes/resources/3C7DDB59DF2D21B287E42A7B908409CB.gif) 22 | 23 | 24 | # Implementations 25 | 26 | | | Language | Link | 27 | |:-: | :-: | :-: | 28 | | | Python | [counting_sort.py](https://github.com/AllAlgorithms/python/blob/master/sorting/counting_sort.py) | 29 | | | C++ | [counting_sort.py](https://github.com/AllAlgorithms/cpp/blob/master/sorting/counting_sort.cpp) | 30 | 31 | 32 | 33 | ## Helpful Links 34 | 35 | - [GeeksForGeeks](https://www.geeksforgeeks.org/counting-sort/) 36 | - [Wikipedia](https://en.wikipedia.org/wiki/Counting_sort) 37 | 38 | ## Videos 39 | 40 | - [Youtube](https://www.youtube.com/watch?v=7zuGmKfUt7s) 41 | -------------------------------------------------------------------------------- /docs/crossword-puzzle.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: crossword-puzzle 3 | title: Crossword Puzzle 4 | sidebar_label: Crossword Puzzle 5 | --- 6 | 7 | **A crossword is a word puzzle** that usually takes the form of a square or a rectangular grid of white-and black-shaded squares. The game's goal is to fill the white squares with letters, forming words or phrases, by solving clues, which lead to the answers. In languages that are written left-to-right, the answer words and phrases are placed in the grid from left to right and from top to bottom. The shaded squares are used to separate the words or phrases. 8 | 9 | 10 | 11 | ## A basic crossword-solving algorithm 12 | 13 | A large part of the research on this project centered around the creation and refinement of the following algorithm for filling in a crossword grid (under the character-based model described above). It takes as input a grid and a word list; with minor variations, the same algorithm can be used either to solve a puzzle (in which case the grid is input with "stops" already in place, and the word list is (possibly a subset of) the dictionary) or to generate a puzzle solution (in which case the grid is initially empty and the word list contains the words to fill into the grid). 14 | 15 | Note that a subgrid, as used in the algorithm, is a section of the grid space whose upper left square is the first letter of both its horizontal and vertical words; the subgrid then extends to all squares which are part of words which intersect either the horizontal or vertical word starting from the initial position. 16 | 17 | 18 | - Initialization: Set all the squares in the grid to their unconstrained state, that is all character values are possible. (For solving purposes, this is A-Z; for generation, A-Z plus a stop indicator, such as NUL.) 19 | - Repeat the following for each subgrid: 20 | - For each of the possible character values of the initial (upper left) position, get all words from the word list which begin with the given character, and which satisfy the length constraints for the down and across words, respectively. If there is not at least one word which satisfies the length and initial letter constraints for each of the two words (that is, there must be at least one valid across word and one valid down word), move to the next character value. Otherwise: 21 | - "Write in" each of the words which were determined to meet the across criteria into the grid, moving righward from the initial cell as you go. For each character written, maintain a reference to what word caused it to be written in. 22 | - If at any point a letter cannot be written into a cell because it is no longer a possible value for the cell, remove the current word from the grid and proceed to the next word. 23 | - Repeat the above two steps for the down words, starting from the initial position and moving downward. 24 | - Move to the cell to the right of the initial position. For each character in the list of possible values, find all words which meet the length and initial letter constraints (i.e. start with the correct letter and are the proper length). Call this list words. 25 | - If words is empty, delete the current character from the list of possible values. Propagate the deletion backwards and forwards in the grid by removing the word which caused the deleted character to be written in. Repeat as necessary; if a cell ever loses all of its possible values, terminate the algorithm and return FAIL. 26 | - "Write in" each of the words, as above. If a letter must be written into a cell for which it is not a possible value, remove the current word and propagate the changes. 27 | Repeat the above step for each row of the grid, for the length of the initial down word. This should completely traverse the subgrid. 28 | - When all subgrids have been filled in, the grid should contain a representation of all possible solutions. Output either one or all possible solutions using one of any number of algorithms for enumerating the solutions. (The grid consists of a collapsed tree of possible solutions, with each cell representing all the possible values for that cell.) 29 | 30 | ## Example 31 | 32 | A 10 x 10 Crossword grid is provided, along with a set of words (or names of places) which need to be filled into the grid. The cells in the grid are initially, either + signs or – signs. Cells marked with a ‘+’ have to be left as they are. Cells marked with a ‘-‘ need to be filled up with an appropriate character. 33 | You are also given an array of words that need to be filled in Crossword grid. 34 | 35 | ```cpp 36 | #include 37 | using namespace std; 38 | 39 | // ways are to calculate the number of 40 | // possible ways to fill the grid 41 | int ways = 0; 42 | 43 | // this function is used to print 44 | // the resultant matrix 45 | void printMatrix(vector& matrix, int n) 46 | { 47 | for (int i = 0; i < n; i++) 48 | cout << matrix[i] << endl; 49 | } 50 | 51 | // this function checks for the current word 52 | // if it can be placed horizontally or not 53 | // x -> it represent index of row 54 | // y -> it represent index of column 55 | // currentWord -> it represent the 56 | // current word in word array 57 | vector checkHorizontal(int x, int y, 58 | vector matrix, 59 | string currentWord) 60 | { 61 | int n = currentWord.length(); 62 | 63 | for (int i = 0; i < n; i++) { 64 | if (matrix[x][y + i] == '#' || 65 | matrix[x][y + i] == currentWord[i]) { 66 | matrix[x][y + i] = currentWord[i]; 67 | } 68 | else { 69 | 70 | // this shows that word cannot 71 | // be placed horizontally 72 | matrix[0][0] = '@'; 73 | return matrix; 74 | } 75 | } 76 | 77 | return matrix; 78 | } 79 | 80 | // this function checks for the current word 81 | // if it can be placed vertically or not 82 | // x -> it represent index of row 83 | // y -> it represent index of column 84 | // currentWord -> it represent the 85 | // current word in word array 86 | vector checkVertical(int x, int y, 87 | vector matrix, 88 | string currentWord) 89 | { 90 | int n = currentWord.length(); 91 | 92 | for (int i = 0; i < n; i++) { 93 | if (matrix[x + i][y] == '#' || 94 | matrix[x + i][y] == currentWord[i]) { 95 | matrix[x + i][y] = currentWord[i]; 96 | } 97 | else { 98 | 99 | // this shows that word 100 | // cannot be placed vertically 101 | matrix[0][0] = '@'; 102 | return matrix; 103 | } 104 | } 105 | return matrix; 106 | } 107 | 108 | // this function recursively checks for every 109 | // word that can align vertically in one loop 110 | // and in another loop it checks for those words 111 | // that can align horizontally words -> it 112 | // contains all the words to fill in a crossword 113 | // puzzle matrix -> it contain the current 114 | // state of crossword index -> it represent 115 | // the index of current word n -> it represent 116 | // the length of row or column of the square matrix 117 | void solvePuzzle(vector& words, 118 | vector matrix, 119 | int index, int n) 120 | { 121 | if (index < words.size()) { 122 | string currentWord = words[index]; 123 | int maxLen = n - currentWord.length(); 124 | 125 | // loop to check the words that can align vertically. 126 | for (int i = 0; i < n; i++) { 127 | for (int j = 0; j <= maxLen; j++) { 128 | vector temp = checkVertical(j, i, 129 | matrix, currentWord); 130 | 131 | if (temp[0][0] != '@') { 132 | solvePuzzle(words, temp, index + 1, n); 133 | } 134 | } 135 | } 136 | 137 | // loop to check the words that can align horizontally. 138 | for (int i = 0; i < n; i++) { 139 | for (int j = 0; j <= maxLen; j++) { 140 | vector temp = checkHorizontal(i, j, 141 | matrix, currentWord); 142 | 143 | if (temp[0][0] != '@') { 144 | solvePuzzle(words, temp, index + 1, n); 145 | } 146 | } 147 | } 148 | } 149 | else { 150 | // calling of print function to 151 | // print the crossword puzzle 152 | cout << (ways + 1) << " way to solve the puzzle " 153 | << endl; 154 | printMatrix(matrix, n); 155 | cout << endl; 156 | 157 | // increase the ways 158 | ways++; 159 | return; 160 | } 161 | } 162 | 163 | // Driver Code 164 | int main() 165 | { 166 | // length of grid 167 | int n1 = 10; 168 | 169 | // matrix to hold the grid of puzzle 170 | vector matrix; 171 | 172 | // take input of puzzle in matrix 173 | // input of grid of size n1 x n1 174 | matrix.push_back("*#********"); 175 | matrix.push_back("*#********"); 176 | matrix.push_back("*#****#***"); 177 | matrix.push_back("*##***##**"); 178 | matrix.push_back("*#****#***"); 179 | matrix.push_back("*#****#***"); 180 | matrix.push_back("*#****#***"); 181 | matrix.push_back("*#*######*"); 182 | matrix.push_back("*#********"); 183 | matrix.push_back("***#######"); 184 | 185 | vector words; 186 | 187 | // the words matrix will hold all 188 | // the words need to be filled in the grid 189 | words.push_back("PUNJAB"); 190 | words.push_back("JHARKHAND"); 191 | words.push_back("MIZORAM"); 192 | words.push_back("MUMBAI"); 193 | 194 | // initialize the number of ways 195 | // to solve the puzzle to zero 196 | ways = 0; 197 | 198 | // recursive function to solve the puzzle 199 | // Here 0 is the initial index of words array 200 | // n1 is length of grid 201 | solvePuzzle(words, matrix, 0, n1); 202 | cout << "Number of ways to fill the grid is " 203 | << ways << endl; 204 | 205 | return 0; 206 | } 207 | ``` 208 | 209 | ## Implementations 210 | 211 | | | Language | Link | 212 | |:-: | :-: | :-: | 213 | | | Java | [CrosswordPuzzle.java](https://github.com/AllAlgorithms/java/blob/master/backtracking/CrosswordPuzzle.java) | 214 | | | C++ | [crossword_puzzle.cpp](https://github.com/AllAlgorithms/cpp/blob/master/backtracking/crossword_puzzle.cpp) | 215 | 216 | ## Videos 217 | 218 | - [CrossWord Generator in C++ (part 1)](https://www.youtube.com/watch?v=L9vjKr1TYec) 219 | - [CrossWord Generator in C++ (part 2)](https://www.youtube.com/watch?v=j7yAYBJnc58) 220 | - [Stackathon Presentation: TRegex: A Regex Crossword Solver](https://www.youtube.com/watch?v=qo_3rtEZdKg) 221 | 222 | ## Helpful Links 223 | 224 | - University of Columbia paper: [Crossword Puzzles as Constraint Satisfaction Problems](http://www.cs.columbia.edu/~evs/ais/finalprojs/steinthal/) 225 | - StackOverflow: [Algorithm to generate a crossword](https://stackoverflow.com/questions/943113/algorithm-to-generate-a-crossword) 226 | - Game mixed crossword puzzle with Regular Expressions: [RegexCrossword.com](https://regexcrossword.com/) --- 227 | id: crossword-puzzle 228 | title: Crossword puzzle 229 | sidebar_label: Crossword puzzle 230 | --- 231 | 232 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/crossword-puzzle.md) to add the content for this algorithm. 233 | -------------------------------------------------------------------------------- /docs/cycle-sort.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: cycle-sort 3 | title: Cycle sort 4 | sidebar_label: Cycle sort 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/cycle-sort.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/dbscan.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: dbscan 3 | title: Dbscan 4 | sidebar_label: Dbscan 5 | --- 6 | 7 | **Density-based spatial clustering of applications with noise (DBSCAN)** is a data clustering algorithm proposed by Martin Ester, Hans-Peter Kriegel, Jörg Sander and Xiaowei Xu in 1996. It is a density-based clustering algorithm: given a set of points in some space, it groups together points that are closely packed together (points with many nearby neighbors), marking as outliers points that lie alone in low-density regions (whose nearest neighbors are too far away). DBSCAN is one of the most common clustering algorithms and also most cited in scientific literature. 8 | 9 | 10 | 11 | 12 | ## Preliminary 13 | 14 | Consider a set of points in some space to be clustered. For the purpose of DBSCAN clustering, the points are classified as core points, (density-)reachable points and outliers, as follows: 15 | 16 | - A point `p` is a core point if at least minPts points are within distance ε (ε is the maximum radius of the neighborhood from p) of it (including p). Those points are said to be directly reachable from p. 17 | - A point q is directly reachable from `p` if point q is within distance ε from point `p` and `p` must be a core point. 18 | - A point q is reachable from `p` if there is a path `p1`, `...`, `pn` with `p1 = p` and `pn = q`, where each `pi+1` is directly reachable from pi (all the points on the path must be core points, with the possible exception of q). 19 | - All points not reachable from any other point are outliers. 20 | 21 | Now if `p` is a core point, then it forms a cluster together with all points (core or non-core) that are reachable from it. Each cluster contains at least one core point; non-core points can be part of a cluster, but they form its "edge", since they cannot be used to reach more points. 22 | 23 | 24 | 25 | 26 | Reachability is not a symmetric relation since, by definition, no point may be reachable from a non-core point, regardless of distance (so a non-core point may be reachable, but nothing can be reached from it). Therefore, a further notion of connectedness is needed to formally define the extent of the clusters found by DBSCAN. Two points p and q are density-connected if there is a point o such that both p and q are reachable from o. Density-connectedness is symmetric. 27 | 28 | A cluster then satisfies two properties: 29 | 30 | - All points within the cluster are mutually density-connected. 31 | - If a point is density-reachable from any point of the cluster, it is part of the cluster as well. 32 | 33 | 34 | ## Algorithm 35 | 36 | 37 | DBSCAN requires two parameters: ε (eps) and the minimum number of points required to form a dense region (minPts). It starts with an arbitrary starting point that has not been visited. This point's ε-neighborhood is retrieved, and if it contains sufficiently many points, a cluster is started. Otherwise, the point is labeled as noise. Note that this point might later be found in a sufficiently sized ε-environment of a different point and hence be made part of a cluster. 38 | 39 | If a point is found to be a dense part of a cluster, its ε-neighborhood is also part of that cluster. Hence, all points that are found within the ε-neighborhood are added, as is their own ε-neighborhood when they are also dense. This process continues until the density-connected cluster is completely found. Then, a new unvisited point is retrieved and processed, leading to the discovery of a further cluster or noise. 40 | 41 | DBSCAN can be used with any distance function (as well as similarity functions or other predicates). The distance function (dist) can therefore be seen as an additional parameter. 42 | 43 | The algorithm can be expressed in pseudocode as follows: 44 | 45 | ``` 46 | DBSCAN(DB, distFunc, eps, minPts) { 47 | C = 0 /* Cluster counter */ 48 | for each point P in database DB { 49 | if label(P) ≠ undefined then continue /* Previously processed in inner loop */ 50 | Neighbors N = RangeQuery(DB, distFunc, P, eps) /* Find neighbors */ 51 | if |N| < minPts then { /* Density check */ 52 | label(P) = Noise /* Label as Noise */ 53 | continue 54 | } 55 | C = C + 1 /* next cluster label */ 56 | label(P) = C /* Label initial point */ 57 | Seed set S = N \ {P} /* Neighbors to expand */ 58 | for each point Q in S { /* Process every seed point */ 59 | if label(Q) = Noise then label(Q) = C /* Change Noise to border point */ 60 | if label(Q) ≠ undefined then continue /* Previously processed */ 61 | label(Q) = C /* Label neighbor */ 62 | Neighbors N = RangeQuery(DB, distFunc, Q, eps) /* Find neighbors */ 63 | if |N| ≥ minPts then { /* Density check */ 64 | S = S ∪ N /* Add new neighbors to seed set */ 65 | } 66 | } 67 | } 68 | } 69 | ``` 70 | 71 | where RangeQuery can be implemented using a database index for better performance, or using a slow linear scan: 72 | 73 | ``` 74 | RangeQuery(DB, distFunc, Q, eps) { 75 | Neighbors = empty list 76 | for each point P in database DB { /* Scan all points in the database */ 77 | if distFunc(Q, P) ≤ eps then { /* Compute distance and check epsilon */ 78 | Neighbors = Neighbors ∪ {P} /* Add to result */ 79 | } 80 | } 81 | return Neighbors 82 | } 83 | ``` 84 | 85 | ## Complexity 86 | 87 | DBSCAN visits each point of the database, possibly multiple times (e.g., as candidates to different clusters). For practical considerations, however, the time complexity is mostly governed by the number of regionQuery invocations. DBSCAN executes exactly one such query for each point, and if an indexing structure is used that executes a neighborhood query in O(log n), an overall average runtime complexity of O(n log n) is obtained (if parameter ε is chosen in a meaningful way, i.e. such that on average only O(log n) points are returned). Without the use of an accelerating index structure, or on degenerated data (e.g. all points within a distance less than ε), the worst case run time complexity remains O(n²). The distance matrix of size (n²-n)/2 can be materialized to avoid distance recomputations, but this needs O(n²) memory, whereas a non-matrix based implementation of DBSCAN only needs O(n) memory. 88 | 89 | 90 | 91 | > DBSCAN can find non-linearly separable clusters. This dataset cannot be adequately clustered with k-means or Gaussian Mixture EM clustering 92 | 93 | ## Implementation 94 | 95 | | | Language | Link | 96 | |:-: | :-: | :-: | 97 | | | Python | [dbscan.py](https://github.com/AllAlgorithms/python/blob/master/artificial-intelligence/dbscan.py) | 98 | 99 | 100 | ## Helpful Links 101 | 102 | - [Wikipedia](https://en.wikipedia.org/wiki/DBSCAN) 103 | 104 | ## Videos 105 | 106 | - [Youtube](https://www.youtube.com/watch?v=9oe43bVLxzk) 107 | 108 | -------------------------------------------------------------------------------- /docs/decision-tree.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: decision-tree 3 | title: Decision tree 4 | sidebar_label: Decision tree 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/decision-tree.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/decoding-of-string.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: decoding-of-string 3 | title: Decoding of string 4 | sidebar_label: Decoding of string 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/decoding-of-string.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/delannoy-number.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: delannoy-number 3 | title: Delannoy number 4 | sidebar_label: Delannoy number 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/delannoy-number.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/derangements.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: derangements 3 | title: Derangements 4 | sidebar_label: Derangements 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/derangements.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/determine-endianess.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: determine-endianess 3 | title: Determine endianess 4 | sidebar_label: Determine endianess 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/determine-endianess.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/dfa-division.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: dfa-division 3 | title: Dfa division 4 | sidebar_label: Dfa division 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/dfa-division.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/dijkstra-shortest-path.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: dijkstra-shortest-path 3 | title: Dijkstra shortest path 4 | sidebar_label: Dijkstra shortest path 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/dijkstra-shortest-path.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/diophantine.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: diophantine 3 | title: Diophantine 4 | sidebar_label: Diophantine 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/diophantine.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/distance-between-points.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: distance-between-points 3 | title: Distance between points 4 | sidebar_label: Distance between points 5 | --- 6 | 7 | The **distance between two points** can have several different 8 | definitions depending on the specific situation, although without any 9 | further specification it usually refers to the length of the segment 10 | connecting the two points (also called [*Euclidean distance*][euclidean]). 11 | 12 | ## Euclidean Distance 13 | 14 | The [Euclidean distance][euclidean] is generally defined as the lenght 15 | of the segment connecting two points. 16 | 17 | Euclidean distance 20 | 21 | ### Formula 22 | 23 | The [Euclidean distance][euclidean] can be easily calculated when the 24 | coordinates of the two points are known. For example, in the XY plane, 25 | the formulas would be the following: 26 | 27 | P = (P_x, P_y) 30 | 31 | Q = (Q_x, Q_y) 34 | 35 | d(P, Q) = \sqrt{(P_x - Q_x)^2 + (P_y - Q_y)^2} 38 | 39 | The formula above can be generalized for vector spaces of any dimension, 40 | by taking the square root of the sum of the squares of differences in 41 | each dimension: 42 | 43 | P = (P_1, P_2, ..., P_n) 46 | 47 | Q = (Q_1, Q_2, ..., Q_n) 50 | 51 | d(P, Q) = \sqrt{(P_1 - Q_1)^2 + (P_2 - Q_2)^2 + ... + (P_n - Q_n)^2} 54 | 55 | d(P, Q) = \sqrt{\sum_{i=1}^n (P_i - Q_i)^2} 58 | 59 | ### Algorithm 60 | 61 | The algorithm for the [Euclidean distance][euclidean] can be derived 62 | directly from the defining formula above: 63 | 64 | ``` 65 | /* Assume that P and Q are N-dimensional arrays */ 66 | distance(P, Q) { 67 | N = dim(P) 68 | square_sum = 0.0 /* initialize running sum */ 69 | for dimension i from 1 to N { /* iterate over all dimensions */ 70 | square_sum = square_sum + (P[i] - Q[i])^2 /* sum squares of differences */ 71 | } 72 | distance = sqrt(square_sum); /* distance is the square root of the sum of squared differences */ 73 | return distance; 74 | } 75 | ``` 76 | 77 | ## Manhattan Distance 78 | 79 | Among the many possible definitions of distance, another one commonly 80 | found in computer science is the [Manhattan distance][manhattan]. This 81 | is typically a distance used when movements are constrained to happen 82 | over a grid: 83 | 84 | Manhattan distance 87 | 88 | ### Formula 89 | 90 | The formula below applies when calculating the [Manhattan 91 | distance][manhattan] over an N-dimensional grid where adjacent nodes are 92 | assumed to have distance 1: 93 | 94 | P = (P_1, P_2, ..., P_n) 97 | 98 | Q = (Q_1, Q_2, ..., Q_n) 101 | 102 | d(P, Q) = \sum_{i=1}^n |P_i - Q_i| 105 | 106 | ### Algorithm 107 | 108 | The algorithm can be implemented as a direct derivation of the formula: 109 | 110 | ``` 111 | /* Assume that P and Q are N-dimensional arrays */ 112 | manhattan_distance(P, Q) { 113 | N = dim(P) 114 | distance = 0.0 /* initialize running sum */ 115 | for dimension i from 1 to N { /* iterate over all dimensions */ 116 | distance = distance + abs(P[i] - Q[i]) /* sum squares of differences */ 117 | } 118 | return distance; 119 | } 120 | ``` 121 | 122 | ## Minkowski Distance 123 | 124 | **Minkowski Distance** is a metric in a normed vector space which can be considered as a generalization of both the Euclidean distance and the Manhattan distance. It is named after the German mathematician Hermann Minkowski. 125 | 126 | ### Formula 127 | 128 | The formula below applies when calculating the Minkowski distance over an N-dimensional grid: 129 | 130 | $P = (p_1, p_2, ..., p_n)\\$ 131 | $Q = (q_1, q_2, ..., q_n)\\$ 132 | $d(P, Q) = \left( \sum_{i=1}^{n} |p_i - q_i|^m \right) ^ {\frac{1}{m}}$ 133 | 134 | ### Algorithm 135 | 136 | ``` 137 | /* Assume that P and Q are N-dimensional arrays */ 138 | manhattan_distance(P, Q) { 139 | N = dim(P) 140 | distance = 0.0 /* initialize running sum */ 141 | for dimension i from 1 to N { /* iterate over all dimensions */ 142 | distance = distance + abs(P[i] - Q[i])^m /* sum the processed differences */ 143 | } 144 | return distance^(1/m); 145 | } 146 | ``` 147 | 148 | 149 | ## Performance 150 | 151 | Both Euclidean and Manhattan distance algorithms for each respective distance definition are linear 152 | (O(n)) with respect to the number of dimensions with which each point is 153 | represented. The Minkowski distance algorithm's complexity is around O(nm) for n dimensional vector and the factor power m. 154 | 155 | 156 | ## Implementations 157 | 158 | | | Language | Link | 159 | |:-: | :-: | :-: | 160 | | | | | 161 | 162 | ## Helpful Links 163 | 164 | - [Euclidean distance][euclidean] 165 | - [Manhattan distance][manhattan] 166 | - [Minkowski distance][minkowski] 167 | - [Norm][norm] a generalization of the concept of distance 168 | - [Lp space][lp-space] a generalization of a class of norms 169 | 170 | 171 | [euclidean]: https://en.wikipedia.org/wiki/Euclidean_distance 172 | [manhattan]: https://en.wikipedia.org/wiki/Taxicab_geometry 173 | [minkowski]: https://en.wikipedia.org/wiki/Minkowski_distance 174 | [norm]: https://en.wikipedia.org/wiki/Norm_(mathematics) 175 | [lp-space]: https://en.wikipedia.org/wiki/Lp_space 176 | -------------------------------------------------------------------------------- /docs/divided-differences.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: divided-differences 3 | title: Divided differences 4 | sidebar_label: Divided differences 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/divided-differences.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/egyptian-fraction.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: egyptian-fraction 3 | title: Egyptian fraction 4 | sidebar_label: Egyptian fraction 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/egyptian-fraction.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/elementary-cellular-automata.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: elementary-cellular-automata 3 | title: Elementary cellular automata 4 | sidebar_label: Elementary cellular automata 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/elementary-cellular-automata.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/euler-totient.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: euler-totient 3 | title: Euler totient 4 | sidebar_label: Euler totient 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/euler-totient.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/exponential-search.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: exponential-search 3 | title: Exponential search 4 | sidebar_label: Exponential search 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/exponential-search.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/exponentiation-power.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: exponentiation-power 3 | title: Exponentiation power 4 | sidebar_label: Exponentiation power 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/exponentiation-power.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/factorial.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: factorial 3 | title: Factorial 4 | sidebar_label: Factorial 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/factorial.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/factorization-machines.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: factorization-machines 3 | title: Factorization machines 4 | sidebar_label: Factorization machines 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/factorization-machines.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/fast-fourier-transform.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: fast-fourier-transform 3 | title: Fast Fourier Transform 4 | sidebar_label: Fast Fourier Transform 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/fast-fourier-transform.md) to add the content for this algorithm. 8 | -------------------------------------------------------------------------------- /docs/fast-inverse-square-root.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: fast-inverse-square-root 3 | title: Fast inverse square root 4 | sidebar_label: Fast inverse square root 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/fast-inverse-square-root.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/fibonacci-search.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: fibonacci-search 3 | title: Fibonacci search 4 | sidebar_label: Fibonacci search 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/fibonacci-search.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/fifteen-puzzle.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: fifteen-puzzle 3 | title: Fifteen puzzle 4 | sidebar_label: Fifteen puzzle 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/fifteen-puzzle.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/finite-automata.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: finite-automata 3 | title: Finite automata 4 | sidebar_label: Finite automata 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/finite-automata.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/flash-sort.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: flash-sort 3 | title: Flash sort 4 | sidebar_label: Flash sort 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/flash-sort.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/flip-bits.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: flip-bits 3 | title: Flip bits 4 | sidebar_label: Flip bits 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/flip-bits.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/fuzzy-search.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: fuzzy-search 3 | title: Fuzzy search 4 | sidebar_label: Fuzzy search 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/fuzzy-search.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/gaussian-mixtrue-model.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: gaussian-mixtrue-model 3 | title: Gaussian mixtrue model 4 | sidebar_label: Gaussian mixtrue model 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/gaussian-mixtrue-model.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/generic-algorithm.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: generic-algorithm 3 | title: Generic algorithm 4 | sidebar_label: Generic algorithm 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/generic-algorithm.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/gnome-sort.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: gnome-sort 3 | title: Gnome sort 4 | sidebar_label: Gnome sort 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/gnome-sort.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/gradient-boostring-trees.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: gradient-boostring-trees 3 | title: Gradient boostring trees 4 | sidebar_label: Gradient boostring trees 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/gradient-boostring-trees.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/graham-scan.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: graham-scan 3 | title: Graham scan 4 | sidebar_label: Graham scan 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/graham-scan.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/grundy-numbers-kayle-game.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: grundy-numbers-kayle-game 3 | title: Grundy numbers kayle game 4 | sidebar_label: Grundy numbers kayle game 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/grundy-numbers-kayle-game.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/hackerearth.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: hackerearth 3 | title: Hackerearth 4 | sidebar_label: Hackerearth 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/hackerearth.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/hackerrank.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: hackerrank 3 | title: Hackerrank 4 | sidebar_label: Hackerrank 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/hackerrank.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/halfplane-intersection.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: halfplane-intersection 3 | title: Halfplane intersection 4 | sidebar_label: Halfplane intersection 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/halfplane-intersection.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/hamming-distace.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: hamming-distace 3 | title: Hamming distace 4 | sidebar_label: Hamming distace 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/hamming-distace.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/hashes.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: hashes 3 | title: Hashes 4 | sidebar_label: Hashes 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/hashes.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/heap-sort.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: heap-sort 3 | title: Heap sort 4 | sidebar_label: Heap sort 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/heap-sort.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/hierachical-clustering.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: hierachical-clustering 3 | title: Hierachical clustering 4 | sidebar_label: Hierachical clustering 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/hierachical-clustering.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/image-processing.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: image-processing 3 | title: Image processing 4 | sidebar_label: Image processing 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/image-processing.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/insertion-sort.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: insertion-sort 3 | title: Insertion sort 4 | sidebar_label: Insertion sort 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/insertion-sort.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/integral.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: integral 3 | title: Integral 4 | sidebar_label: Integral 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/integral.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/interpolation-search.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: interpolation-search 3 | title: Interpolation search 4 | sidebar_label: Interpolation search 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/interpolation-search.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/intro-sort.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: intro-sort 3 | title: Intro sort 4 | sidebar_label: Intro sort 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/intro-sort.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/inversion-count.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: inversion-count 3 | title: Inversion count 4 | sidebar_label: Inversion count 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/inversion-count.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/invert-bit.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: invert-bit 3 | title: Invert bit 4 | sidebar_label: Invert bit 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/invert-bit.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/isodata.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: isodata 3 | title: Isodata 4 | sidebar_label: Isodata 5 | --- 6 | 7 | The Iterative Self-Organizing Data Analysis Technique (**ISODATA**) method used a set of rule-of-thumb procedures that have 8 | incorporated into an iterative classification algorithm. Many of the steps used in the algorithm are based on the experience obtained through experimentation. The **ISODATA** algorithm is a modification of the [k-means clustering algorithm](k-means) (overcomes the disadvantages of k-means). This algorithm includes the merging of clusters if their separation distance in multispectral feature space is less than a user-specified value and the rules for splitting a single cluster into two clusters. This method makes a large number of passes through the dataset until specified results are obtained. 9 | 10 | **ISODATA** unsupervised classification calculates class means evenly distributed in the data space then iteratively clusters the remaining pixels using minimum distance techniques. Each iteration recalculates means and reclassifies pixels with respect to the new means. Iterative class splitting, merging, and deleting is done based on input threshold parameters. All pixels are classified to the nearest class unless a standard deviation or distance threshold is specified, in which case some pixels may be unclassified if they do not meet the selected criteria. This process continues until the number of pixels in each class changes by less than the selected pixel change threshold or the maximum number of iterations is reached. 11 | 12 | ## Helpful Links 13 | 14 | - [Wikipedia](https://en.wikipedia.org/wiki/Multispectral_pattern_recognition#ISODATA_method) 15 | - [Module ISODATA Clustering for Grids / SAGA-GIS Module Library](http://www.saga-gis.org/saga_tool_doc/2.2.5/imagery_classification_7.html) 16 | - [K-means vs. ISODATA](http://www.wu.ece.ufl.edu/books/EE/communications/UnsupervisedClassification.html) 17 | - [ISODATA](http://enviidl.com/help/Subsystems/envi/Content/FindFeatures/Classification/ClassificationTools/ISODATAClassification.htm) -------------------------------------------------------------------------------- /docs/jaccard-similarity.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: jaccard-similarity 3 | title: Jaccard similarity 4 | sidebar_label: Jaccard similarity 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/jaccard-similarity.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/jarvis-march.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: jarvis-march 3 | title: Jarvis march 4 | sidebar_label: Jarvis march 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/jarvis-march.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/jose-phus-problem.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: jose-phus-problem 3 | title: Jose phus problem 4 | sidebar_label: Jose phus problem 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/jose-phus-problem.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/jump-search.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: jump-search 3 | title: Jump search 4 | sidebar_label: Jump search 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/jump-search.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/k-means.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: k-means 3 | title: K means 4 | sidebar_label: K means 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/k-means.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/k-nearest-neighbors.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: k-nearest-neighbors 3 | title: K nearest neighbors 4 | sidebar_label: K nearest neighbors 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/k-nearest-neighbors.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/karatsuba-multiplication.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: karatsuba-multiplication 3 | title: Karatsuba multiplication 4 | sidebar_label: Karatsuba multiplication 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/karatsuba-multiplication.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/karger-minimum-cut-algorithm.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: karger-minimum-cut-algorithm 3 | title: Karger minimum cut algorithm 4 | sidebar_label: Karger minimum cut algorithm 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/karger-minimum-cut-algorithm.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/kasai-algorithm.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: kasai-algorithm 3 | title: Kasai algorithm 4 | sidebar_label: Kasai algorithm 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/kasai-algorithm.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/kmp-algorithm.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: kmp-algorithm 3 | title: Kmp algorithm 4 | sidebar_label: Kmp algorithm 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/kmp-algorithm.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/knight-tour.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: knight-tour 3 | title: Knight tour 4 | sidebar_label: Knight tour 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/knight-tour.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/kth-smallest-element-algorithm.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: kth-smallest-element-algorithm 3 | title: Kth smallest element algorithm 4 | sidebar_label: Kth smallest element algorithm 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/kth-smallest-element-algorithm.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/langtons-ant.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: langtons-ant 3 | title: Langtons ant 4 | sidebar_label: Langtons ant 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/langtons-ant.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/lapindrom-checker.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: lapindrom-checker 3 | title: Lapindrom checker 4 | sidebar_label: Lapindrom checker 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/lapindrom-checker.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/leap-year.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: leap-year 3 | title: Leap year 4 | sidebar_label: Leap year 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/leap-year.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/leetcode.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: leetcode 3 | title: Leetcode 4 | sidebar_label: Leetcode 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/leetcode.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/levenshtein-distance.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: levenshtein-distance 3 | title: Levenshtein distance 4 | sidebar_label: Levenshtein distance 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/levenshtein-distance.md) to add the content for this algorithm. 8 | -------------------------------------------------------------------------------- /docs/linear-regression.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: linear-regression 3 | title: Linear regression 4 | sidebar_label: Linear regression 5 | --- 6 | 7 | In statistics, linear regression is a linear approach to modeling the relationship between a scalar response (or dependent variable) and one or more explanatory variables (or independent variables). The case of one explanatory variable is called simple linear regression. For more than one explanatory variable, the process is called multiple linear regression. This term is distinct from multivariate linear regression, where multiple correlated dependent variables are predicted, rather than a single scalar variable. 8 | 9 |
10 |
11 | 12 | 13 | 14 |
15 |
16 | 17 | ## Preliminary 18 | 19 | In linear regression, the relationships are modeled using linear predictor functions whose unknown model parameters are estimated from the data. Such models are called linear models. Most commonly, the conditional mean of the response given the values of the explanatory variables (or predictors) is assumed to be an affine function of those values; less commonly, the conditional median or some other quantile is used. Like all forms of regression analysis, linear regression focuses on the conditional probability distribution of the response given the values of the predictors, rather than on the joint probability distribution of all of these variables, which is the domain of multivariate analysis. 20 | 21 | Linear regression was the first type of regression analysis to be studied rigorously, and to be used extensively in practical applications. This is because models which depend linearly on their unknown parameters are easier to fit than models which are non-linearly related to their parameters and because the statistical properties of the resulting estimators are easier to determine. 22 | 23 | Linear regression has many practical uses. Most applications fall into one of the following two broad categories: 24 | 25 | - If the goal is prediction, or forecasting, or error reduction, linear regression can be used to fit a predictive model to an observed data set of values of the response and explanatory variables. After developing such a model, if additional values of the explanatory variables are collected without an accompanying response value, the fitted model can be used to make a prediction of the response. 26 | - If the goal is to explain variation in the response variable that can be attributed to variation in the explanatory variables, linear regression analysis can be applied to quantify the strength of the relationship between the response and the explanatory variables, and in particular to determine whether some explanatory variables may have no linear relationship with the response at all, or to identify which subsets of explanatory variables may contain redundant information about the response. 27 | 28 |
29 |
30 | 31 | 32 | 33 |
34 |
35 | 36 | Linear regression models are often fitted using the least squares approach, but they may also be fitted in other ways, such as by minimizing the "lack of fit" in some other norm (as with least absolute deviations regression), or by minimizing a penalized version of the least squares cost function as in ridge regression (L2-norm penalty) and lasso (L1-norm penalty). Conversely, the least squares approach can be used to fit models that are not linear models. Thus, although the terms "least squares" and "linear model" are closely linked, they are not synonymous. 37 | 38 | ## Github links 39 | 40 | - [llSourcell/linear_regression_live](https://github.com/llSourcell/linear_regression_live) 41 | - [ludobouan/linear-regression-sklearn](https://github.com/ludobouan/linear-regression-sklearn) -------------------------------------------------------------------------------- /docs/linear-search.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: linear-search 3 | title: Linear search 4 | sidebar_label: Linear search 5 | --- 6 | 7 | **Linear Search** or commonly called as sequential search is a method for finding an element within a list. It sequentially checks each element of the list until a match is found or the whole list has been searched. 8 | 9 | ## Algorithm 10 | 11 | Linear Search requires two parameters: the array/list and the key. It traverses the entire array/list starting from the first element to the last element of the array. During the traversal, the algorithm checks if the element is equal to the key. Once it finds an element that equals to the key, the function immediately returns the index. The result will be considered as `NOT FOUND` if there is no any element in the array equals the key. 12 | 13 | The algorithm can be expressed in pseudocode as follows: 14 | 15 | ``` 16 | LinearSearch(array, key){ 17 | idx = 0 18 | for idx = 0...n 19 | if array[idx] = key then 20 | return idx 21 | 22 | return -1 23 | } 24 | ``` 25 | 26 | Here is the simulation of Linear Search Algorithm: 27 | 28 | 29 | Source: Tutorialspoint 30 | 31 | ## Complexity 32 | 33 | As the algorithm traverses entire list during runtime, then it has the complexity O(N). 34 | 35 | ## Implementation 36 | 37 | | | Language | Link | 38 | |:-: | :-: | :-: | 39 | | | Python | [dbscan.py](https://github.com/AllAlgorithms/python/blob/master/algorithms/searches/linear_search.py) | -------------------------------------------------------------------------------- /docs/linked-list.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: linked-list 3 | title: Linked list 4 | sidebar_label: Linked list 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/linked-list.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/lipogram-checker.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: lipogram-checker 3 | title: Lipogram checker 4 | sidebar_label: Lipogram checker 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/lipogram-checker.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/list.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: list 3 | title: List 4 | sidebar_label: List 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/list.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/logistic-regression.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: logistic-regression 3 | title: Logistic regression 4 | sidebar_label: Logistic regression 5 | --- 6 | 7 | In statistics, the logistic model (or logit model) is used to model the probability of a certain class or event existing such as pass/fail, win/lose, alive/dead or healthy/sick. This can be combined to model several classes of events such as determining whether an image contains a cat, dog, lion, etc... Each object being detected in the image would be assigned a probability between 0 and 1 and the sum adding to one. 8 | 9 |
10 |
11 | 12 | 13 | 14 |
15 |
16 | 17 | Logistic regression is a statistical model that in its basic form uses a logistic function to model a binary dependent variable, although many more complex extensions exist. In regression analysis, logistic regression (or logit regression) is estimating the parameters of a logistic model (a form of binary regression). Mathematically, a binary logistic model has a dependent variable with two possible values, such as pass/fail which is represented by an indicator variable, where the two values are labeled "0" and "1". In the logistic model, the log-odds (the logarithm of the odds) for the value labeled "1" is a linear combination of one or more independent variables ("predictors"); the independent variables can each be a binary variable (two classes, coded by an indicator variable) or a continuous variable (any real value). The corresponding probability of the value labeled "1" can vary between 0 (certainly the value "0") and 1 (certainly the value "1"), hence the labeling; the function that converts log-odds to probability is the logistic function, hence the name. The unit of measurement for the log-odds scale is called a logit, from logistic unit, hence the alternative names. Analogous models with a different sigmoid function instead of the logistic function can also be used, such as the probit model; the defining characteristic of the logistic model is that increasing one of the independent variables multiplicatively scales the odds of the given outcome at a constant rate, with each independent variable having its own parameter; for a binary dependent variable this generalizes the odds ratio. 18 | 19 | The binary logistic regression model has extensions to more than two levels of the dependent variable: categorical outputs with more than two values are modeled by multinomial logistic regression, and if the multiple categories are ordered, by ordinal logistic regression, for example the proportional odds ordinal logistic model. The model itself simply models probability of output in terms of input, and does not perform statistical classification (it is not a classifier), though it can be used to make a classifier, for instance by choosing a cutoff value and classifying inputs with probability greater than the cutoff as one class, below the cutoff as the other; this is a common way to make a binary classifier. The coefficients are generally not computed by a closed-form expression, unlike linear least squares; see § Model fitting. The logistic regression as a general statistical model was originally developed and popularized primarily by Joseph Berkson, beginning in Berkson (1944), where he coined "logit"; see § History. -------------------------------------------------------------------------------- /docs/lonely-integer.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: lonely-integer 3 | title: Lonely integer 4 | sidebar_label: Lonely integer 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/lonely-integer.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/m-coloring-problem.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: m-coloring-problem 3 | title: M coloring problem 4 | sidebar_label: M coloring problem 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/m-coloring-problem.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/magic-number.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: magic-number 3 | title: Magic number 4 | sidebar_label: Magic number 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/magic-number.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/magic-square.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: magic-square 3 | title: Magic square 4 | sidebar_label: Magic square 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/magic-square.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/majority-element.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: majority-element 3 | title: Majority element 4 | sidebar_label: Majority element 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/majority-element.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/maximum-contiguous-subsequence-sum.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: maximum-contiguous-subsequence-sum 3 | title: Maximum contiguous subsequence sum 4 | sidebar_label: Maximum contiguous subsequence sum 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/maximum-contiguous-subsequence-sum.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/maximun-xor-value.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: maximun-xor-value 3 | title: Maximun xor value 4 | sidebar_label: Maximun xor value 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/maximun-xor-value.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/median-of-medians.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: median-of-medians 3 | title: Median of medians 4 | sidebar_label: Median of medians 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/median-of-medians.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/median-sort.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: merge-sort 3 | title: Merge Sort 4 | sidebar_label: Merge Sort 5 | --- 6 | 7 | **Density-based spatial clustering of applications with noise (DBSCAN)** is a data clustering algorithm proposed by Martin Ester, Hans-Peter Kriegel, Jörg Sander and Xiaowei Xu in 1996. It is a density-based clustering algorithm: given a set of points in some space, it groups together points that are closely packed together (points with many nearby neighbors), marking as outliers points that lie alone in low-density regions (whose nearest neighbors are too far away). DBSCAN is one of the most common clustering algorithms and also most cited in scientific literature. 8 | 9 | 10 | 11 | 12 | ## Preliminary 13 | 14 | Consider a set of points in some space to be clustered. For the purpose of DBSCAN clustering, the points are classified as core points, (density-)reachable points and outliers, as follows: 15 | 16 | - A point `p` is a core point if at least minPts points are within distance ε (ε is the maximum radius of the neighborhood from p) of it (including p). Those points are said to be directly reachable from p. 17 | - A point q is directly reachable from `p` if point q is within distance ε from point `p` and `p` must be a core point. 18 | - A point q is reachable from `p` if there is a path `p1`, `...`, `pn` with `p1 = p` and `pn = q`, where each `pi+1` is directly reachable from pi (all the points on the path must be core points, with the possible exception of q). 19 | - All points not reachable from any other point are outliers. 20 | 21 | Now if `p` is a core point, then it forms a cluster together with all points (core or non-core) that are reachable from it. Each cluster contains at least one core point; non-core points can be part of a cluster, but they form its "edge", since they cannot be used to reach more points. 22 | 23 | 24 | 25 | 26 | Reachability is not a symmetric relation since, by definition, no point may be reachable from a non-core point, regardless of distance (so a non-core point may be reachable, but nothing can be reached from it). Therefore, a further notion of connectedness is needed to formally define the extent of the clusters found by DBSCAN. Two points p and q are density-connected if there is a point o such that both p and q are reachable from o. Density-connectedness is symmetric. 27 | 28 | A cluster then satisfies two properties: 29 | 30 | - All points within the cluster are mutually density-connected. 31 | - If a point is density-reachable from any point of the cluster, it is part of the cluster as well. 32 | 33 | 34 | ## Algorithm 35 | 36 | 37 | DBSCAN requires two parameters: ε (eps) and the minimum number of points required to form a dense region (minPts). It starts with an arbitrary starting point that has not been visited. This point's ε-neighborhood is retrieved, and if it contains sufficiently many points, a cluster is started. Otherwise, the point is labeled as noise. Note that this point might later be found in a sufficiently sized ε-environment of a different point and hence be made part of a cluster. 38 | 39 | If a point is found to be a dense part of a cluster, its ε-neighborhood is also part of that cluster. Hence, all points that are found within the ε-neighborhood are added, as is their own ε-neighborhood when they are also dense. This process continues until the density-connected cluster is completely found. Then, a new unvisited point is retrieved and processed, leading to the discovery of a further cluster or noise. 40 | 41 | DBSCAN can be used with any distance function (as well as similarity functions or other predicates). The distance function (dist) can therefore be seen as an additional parameter. 42 | 43 | The algorithm can be expressed in pseudocode as follows: 44 | 45 | ``` 46 | DBSCAN(DB, distFunc, eps, minPts) { 47 | C = 0 /* Cluster counter */ 48 | for each point P in database DB { 49 | if label(P) ≠ undefined then continue /* Previously processed in inner loop */ 50 | Neighbors N = RangeQuery(DB, distFunc, P, eps) /* Find neighbors */ 51 | if |N| < minPts then { /* Density check */ 52 | label(P) = Noise /* Label as Noise */ 53 | continue 54 | } 55 | C = C + 1 /* next cluster label */ 56 | label(P) = C /* Label initial point */ 57 | Seed set S = N \ {P} /* Neighbors to expand */ 58 | for each point Q in S { /* Process every seed point */ 59 | if label(Q) = Noise then label(Q) = C /* Change Noise to border point */ 60 | if label(Q) ≠ undefined then continue /* Previously processed */ 61 | label(Q) = C /* Label neighbor */ 62 | Neighbors N = RangeQuery(DB, distFunc, Q, eps) /* Find neighbors */ 63 | if |N| ≥ minPts then { /* Density check */ 64 | S = S ∪ N /* Add new neighbors to seed set */ 65 | } 66 | } 67 | } 68 | } 69 | ``` 70 | 71 | where RangeQuery can be implemented using a database index for better performance, or using a slow linear scan: 72 | 73 | ``` 74 | RangeQuery(DB, distFunc, Q, eps) { 75 | Neighbors = empty list 76 | for each point P in database DB { /* Scan all points in the database */ 77 | if distFunc(Q, P) ≤ eps then { /* Compute distance and check epsilon */ 78 | Neighbors = Neighbors ∪ {P} /* Add to result */ 79 | } 80 | } 81 | return Neighbors 82 | } 83 | ``` 84 | 85 | ## Complexity 86 | 87 | DBSCAN visits each point of the database, possibly multiple times (e.g., as candidates to different clusters). For practical considerations, however, the time complexity is mostly governed by the number of regionQuery invocations. DBSCAN executes exactly one such query for each point, and if an indexing structure is used that executes a neighborhood query in O(log n), an overall average runtime complexity of O(n log n) is obtained (if parameter ε is chosen in a meaningful way, i.e. such that on average only O(log n) points are returned). Without the use of an accelerating index structure, or on degenerated data (e.g. all points within a distance less than ε), the worst case run time complexity remains O(n²). The distance matrix of size (n²-n)/2 can be materialized to avoid distance recomputations, but this needs O(n²) memory, whereas a non-matrix based implementation of DBSCAN only needs O(n) memory. 88 | 89 | 90 | 91 | > DBSCAN can find non-linearly separable clusters. This dataset cannot be adequately clustered with k-means or Gaussian Mixture EM clustering 92 | 93 | ## Implementations 94 | 95 | | | Language | Link | 96 | |:-: | :-: | :-: | 97 | | | Python | [dbscan.py](https://github.com/AllAlgorithms/python/blob/master/artificial-intelligence/dbscan.py) | 98 | 99 | 100 | ## Helpful Links 101 | 102 | - [Wikipedia](https://en.wikipedia.org/wiki/DBSCAN) 103 | 104 | ## Videos 105 | 106 | - [Youtube](https://www.youtube.com/watch?v=9oe43bVLxzk) 107 | 108 | 109 | -------------------------------------------------------------------------------- /docs/merge-sort-using-divide-and-conquer.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: merge-sort-using-divide-and-conquer 3 | title: Merge sort using divide and conquer 4 | sidebar_label: Merge sort using divide and conquer 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/merge-sort-using-divide-and-conquer.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/merge-sort.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: merge-sort 3 | title: Merge sort 4 | sidebar_label: Merge sort 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/merge-sort.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/minimax.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: minimax 3 | title: Minimax 4 | sidebar_label: Minimax 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/minimax.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/minimum-subarray-size-with-degree.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: minimum-subarray-size-with-degree 3 | title: Minimum subarray size with degree 4 | sidebar_label: Minimum subarray size with degree 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/minimum-subarray-size-with-degree.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/monte-carlo.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: monte-carlo 3 | title: Monte carlo 4 | sidebar_label: Monte carlo 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/monte-carlo.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/n-queen.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: n-queen 3 | title: N queen 4 | sidebar_label: N queen 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/n-queen.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/native-bayes.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: native-bayes 3 | title: Native bayes 4 | sidebar_label: Native bayes 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/native-bayes.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/nearest-sequence-memory.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: nearest-sequence-memory 3 | title: Nearest sequence memory 4 | sidebar_label: Nearest sequence memory 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/nearest-sequence-memory.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/neutral-network.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: neutral-network 3 | title: Neutral network 4 | sidebar_label: Neutral network 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/neutral-network.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/neutral-style-transfer.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: neutral-style-transfer 3 | title: Neutral style transfer 4 | sidebar_label: Neutral style transfer 5 | --- 6 | 7 | Neural Style Transfer (**NST**) refers to a class of software algorithms that manipulate digital images, or videos, to adopt the appearance or visual style of another image. **NST** algorithms are characterized by their use of deep neural networks in order to perform the image transformation. Common uses for **NST** are the creation of artificial artwork from photographs, for example by transferring the appearance of famous paintings to user supplied photographs. Several notable mobile apps use NST techniques for this purpose, including DeepArt and Prisma. 8 | 9 |
10 | 11 |
12 | 13 | ## Pleriminary 14 | 15 | **NST** is an example of image stylization, a problem studied for over two decades within the field of non-photorealistic rendering. Prior to NST, the transfer of image style was performed using machine learning techniques based on image analogy. Given a training pair of images–a photo and an artwork depicting that photo–a transformation could be learned and then applied to create a new artwork from a new photo, by analogy. The drawback of this method is that such a training pair rarely exists in practice. For example original source material (photos) are rarely available for famous artworks. 16 | 17 |
18 | 19 |
20 | 21 | NST requires no such pairing; only a single example of artwork is needed for the algorithm to transfer its style. 22 | 23 | ## Helpful Links 24 | 25 | - [Wikipedia](https://en.wikipedia.org/wiki/Neural_Style_Transfer) 26 | 27 | ## Videos 28 | 29 | 33 | 34 | -------------------------------------------------------------------------------- /docs/nim-next-best-move-game.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: nim-next-best-move-game 3 | title: Nim next best move game 4 | sidebar_label: Nim next best move game 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/nim-next-best-move-game.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/nim-win-loss-game.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: nim-win-loss-game 3 | title: Nim win loss game 4 | sidebar_label: Nim win loss game 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/nim-win-loss-game.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/no-operator-addition.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: no-operator-addition 3 | title: No operator addition 4 | sidebar_label: No operator addition 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/no-operator-addition.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/nobili-cellular-automata.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: nobili-cellular-automata 3 | title: Nobili cellular automata 4 | sidebar_label: Nobili cellular automata 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/nobili-cellular-automata.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/number-of-ways-in-maze.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: number-of-ways-in-maze 3 | title: Number of ways in maze 4 | sidebar_label: Number of ways in maze 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/number-of-ways-in-maze.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/optima-binary-search-tree.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: optima-binary-search-tree 3 | title: Optima binary search tree 4 | sidebar_label: Optima binary search tree 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/optima-binary-search-tree.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/packet-sniffer.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: packet-sniffer 3 | title: Packet sniffer 4 | sidebar_label: Packet sniffer 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/packet-sniffer.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/paint-fill.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: paint-fill 3 | title: Paint fill 4 | sidebar_label: Paint fill 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/paint-fill.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/partitions-of-set.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: partitions-of-set 3 | title: Partitions of set 4 | sidebar_label: Partitions of set 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/partitions-of-set.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/perceptron.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: perceptron 3 | title: Perceptron 4 | sidebar_label: Perceptron 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/perceptron.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/permutation-of-strings.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: permutation-of-strings 3 | title: Permutation of strings 4 | sidebar_label: Permutation of strings 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/permutation-of-strings.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/pigeonhole-sort.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: pigeonhole-sort 3 | title: Pigeonhole sort 4 | sidebar_label: Pigeonhole sort 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/pigeonhole-sort.md) to add the content for this algorithm. 8 | -------------------------------------------------------------------------------- /docs/power-of-2.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: power-of-2 3 | title: Power of 2 4 | sidebar_label: Power of 2 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/power-of-2.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/powerset.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: powerset 3 | title: Powerset 4 | sidebar_label: Powerset 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/powerset.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/principal-component-analysis.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: principal-component-analysis 3 | title: Principal component analysis 4 | sidebar_label: Principal component analysis 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/principal-component-analysis.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/project-euler.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: project-euler 3 | title: Project euler 4 | sidebar_label: Project euler 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/project-euler.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/q-learning.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: q-learning 3 | title: Q learning 4 | sidebar_label: Q learning 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/q-learning.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/queue.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: queue 3 | title: Queue 4 | sidebar_label: Queue 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/queue.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/quick-select.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: quick-select 3 | title: Quick select 4 | sidebar_label: Quick select 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/quick-select.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/quick-sort-using-divide-and-conquer.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: quick-sort-using-divide-and-conquer 3 | title: Quick sort using divide and conquer 4 | sidebar_label: Quick sort using divide and conquer 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/quick-sort-using-divide-and-conquer.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/quick-sort.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: quick-sort 3 | title: Quick sort 4 | sidebar_label: Quick sort 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/quick-sort.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/quickhull.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: quickhull 3 | title: Quickhull 4 | sidebar_label: Quickhull 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/quickhull.md) to add the content for this algorithm. 8 | -------------------------------------------------------------------------------- /docs/radix-sort.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: radix-sort 3 | title: Radix sort 4 | sidebar_label: Radix sort 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/radix-sort.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/random-forest.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: random-forest 3 | title: Random forest 4 | sidebar_label: Random forest 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/random-forest.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/random-from-stream.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: random-from-stream 3 | title: Random from stream 4 | sidebar_label: Random from stream 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/random-from-stream.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/random-node-linked-list.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: random-node-linked-list 3 | title: Random node linked list 4 | sidebar_label: Random node linked list 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/random-node-linked-list.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/randomized-quicksort.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: randomized-quicksort 3 | title: Randomized quicksort 4 | sidebar_label: Randomized quicksort 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/randomized-quicksort.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/rat-in-maze.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: rat-in-maze 3 | title: Rat in maze 4 | sidebar_label: Rat in maze 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/rat-in-maze.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/reservoir-sampling.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: reservoir-sampling 3 | title: Reservoir sampling 4 | sidebar_label: Reservoir sampling 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/reservoir-sampling.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/restricted-boltzman-machine.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: restricted-boltzman-machine 3 | title: Restricted boltzman machine 4 | sidebar_label: Restricted boltzman machine 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/restricted-boltzman-machine.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/rosalind.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: rosalind 3 | title: Rosalind 4 | sidebar_label: Rosalind 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/rosalind.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/runge-kutt.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: runge-kutt 3 | title: Runge kutt 4 | sidebar_label: Runge kutt 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/runge-kutt.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/sat.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: sat 3 | title: Boolean satisfiability problem 4 | sidebar_label: Sat 5 | --- 6 | 7 | In computer science, the Boolean satisfiability problem (sometimes called propositional satisfiability problem and abbreviated **SATISFIABILITY** or **SAT**) is the problem of determining if there exists an interpretation that satisfies a given Boolean formula. In other words, it asks whether the variables of a given Boolean formula can be consistently replaced by the values TRUE or FALSE in such a way that the formula evaluates to TRUE. If this is the case, the formula is called satisfiable. On the other hand, if no such assignment exists, the function expressed by the formula is FALSE for all possible variable assignments and the formula is unsatisfiable. For example, the formula "a AND NOT b" is satisfiable because one can find the values a = TRUE and b = FALSE, which make (a AND NOT b) = TRUE. In contrast, "a AND NOT a" is unsatisfiable. 8 | 9 |
10 | 11 | 12 |
13 |
14 | 15 | **SAT** is the first problem that was proven to be NP-complete; see Cook–Levin theorem. This means that all problems in the complexity class NP, which includes a wide range of natural decision and optimization problems, are at most as difficult to solve as SAT. There is no known algorithm that efficiently solves each SAT problem, and it is generally believed that no such algorithm exists; yet this belief has not been proven mathematically, and resolving the question of whether SAT has a polynomial-time algorithm is equivalent to the P versus NP problem, which is a famous open problem in the theory of computing. 16 | 17 | Nevertheless, as of 2007, heuristic SAT-algorithms are able to solve problem instances involving tens of thousands of variables and formulas consisting of millions of symbols, which is sufficient for many practical SAT problems from, e.g., artificial intelligence, circuit design, and automatic theorem proving. 18 | 19 |
20 | 21 |
22 |
23 | 24 | ## Helpful Links 25 | 26 | - [Boolean satisfiability problem on Wikipedia](https://en.wikipedia.org/wiki/Boolean_satisfiability_problem) 27 | - [Fundamental Algorithms for System Modeling, Analysis, and Optimization, SAT Solving](https://ptolemy.berkeley.edu/projects/embedded/eecsx44/fall2011/lectures/SATSolving.pdf) 28 | - [The Satisfiability Problem](http://infolab.stanford.edu/~ullman/ialc/spr10/slides/pnp2.pdf) -------------------------------------------------------------------------------- /docs/selection-sort.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: selection-sort 3 | title: Selection sort 4 | sidebar_label: Selection sort 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/selection-sort.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/shaker-sort.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: shaker-sort 3 | title: Shaker sort 4 | sidebar_label: Shaker sort 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/shaker-sort.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/shell-sort.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: shell-sort 3 | title: Shell sort 4 | sidebar_label: Shell sort 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/shell-sort.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/shuffle-an-array.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: shuffle-an-array 3 | title: Shuffle an array 4 | sidebar_label: Shuffle an array 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/shuffle-an-array.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/sleep-sort.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: sleep-sort 3 | title: Sleep sort 4 | sidebar_label: Sleep sort 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/sleep-sort.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/sphere-tetrahedron-intersection.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: sphere-tetrahedron-intersection 3 | title: Sphere tetrahedron intersection 4 | sidebar_label: Sphere tetrahedron intersection 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/sphere-tetrahedron-intersection.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/split-list.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: split-list 3 | title: Split list 4 | sidebar_label: Split list 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/split-list.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/spoj.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: spoj 3 | title: Spoj 4 | sidebar_label: Spoj 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/spoj.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/stack.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: stack 3 | title: Stack 4 | sidebar_label: Stack 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/stack.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/stooge-sort.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: stooge-sort 3 | title: Stooge sort 4 | sidebar_label: Stooge sort 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/stooge-sort.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/strassen-matrix-manipulation.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: strassen-matrix-manipulation 3 | title: Strassen matrix manipulation 4 | sidebar_label: Strassen matrix manipulation 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/strassen-matrix-manipulation.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/subset-generation.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: subset-generation 3 | title: Subset generation 4 | sidebar_label: Subset generation 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/subset-generation.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/subset-sum.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: subset-sum 3 | title: Subset sum 4 | sidebar_label: Subset sum 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/subset-sum.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/sudoku-solve.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: sudoku-solve 3 | title: Sudoku solve 4 | sidebar_label: Sudoku solve 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/sudoku-solve.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/sum-binary-numbers.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: sum-binary-numbers 3 | title: Sum binary numbers 4 | sidebar_label: Sum binary numbers 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/sum-binary-numbers.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/sum-equals-xor.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: sum-equals-xor 3 | title: Sum equals xor 4 | sidebar_label: Sum equals xor 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/sum-equals-xor.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/sutherland-hodgman-clipping.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: sutherland-hodgman-clipping 3 | title: Sutherland-Hodgman clipping 4 | sidebar_label: Sutherland-Hodgman clipping 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/sutherland-hodgman-clipping.md) to add the content for this algorithm. 8 | -------------------------------------------------------------------------------- /docs/ternay-search.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: ternay-search 3 | title: Ternay search 4 | sidebar_label: Ternay search 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/ternay-search.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/thrice-unique-number.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: thrice-unique-number 3 | title: Thrice unique number 4 | sidebar_label: Thrice unique number 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/thrice-unique-number.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/tokenizer.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: tokenizer 3 | title: Tokenizer 4 | sidebar_label: Tokenizer 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/tokenizer.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/top-coder.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: top-coder 3 | title: Top coder 4 | sidebar_label: Top coder 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/top-coder.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/topological-sort.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: topological-sort 3 | title: Topological sort 4 | sidebar_label: Topological sort 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/topological-sort.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/tournament-method-to-find-min-max.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: tournament-method-to-find-min-max 3 | title: Tournament method to find min max 4 | sidebar_label: Tournament method to find min max 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/tournament-method-to-find-min-max.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/tree-sort.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: tree-sort 3 | title: Tree sort 4 | sidebar_label: Tree sort 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/tree-sort.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/tree.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: tree 3 | title: Tree 4 | sidebar_label: Tree 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/tree.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/tsp.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: tsp 3 | title: Tsp 4 | sidebar_label: Tsp 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/tsp.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/twice-unique-number.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: twice-unique-number 3 | title: Twice unique number 4 | sidebar_label: Twice unique number 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/twice-unique-number.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/unique-number.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: unique-number 3 | title: Unique number 4 | sidebar_label: Unique number 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/unique-number.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/validate-ip.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: validate-ip 3 | title: Validate ip 4 | sidebar_label: Validate ip 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/validate-ip.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/vigenere-cipher.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: vigenere-cipher 3 | title: Vigenere cipher 4 | sidebar_label: Vigenere cipher 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/vigenere-cipher.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/von-neoumann-cellular-automata.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: von-neoumann-cellular-automata 3 | title: Von neoumann cellular automata 4 | sidebar_label: Von neoumann cellular automata 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/von-neoumann-cellular-automata.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/warnock-algorithm.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: warnock-algorithm 3 | title: Warnock algorithm 4 | sidebar_label: Warnock algorithm 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/warnock-algorithm.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/x-power-y.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: x-power-y 3 | title: X power y 4 | sidebar_label: X power y 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/x-power-y.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /docs/xor-swap.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: xor-swap 3 | title: Xor swap 4 | sidebar_label: Xor swap 5 | --- 6 | 7 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/xor-swap.md) to add the content for this algorithm. -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 All Algorithms and its contributors (allalgorithms.com) 4 | Copyright (c) 2018 Carlos Abraham (abranhe.com) 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /netlify.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | base = "website" 3 | publish = "website/build/algorithms" 4 | command = "npm run build" -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "repos": "node scripts/repos.js", 4 | "change": "node scripts/change.js", 5 | "add": "node scripts/git-add.js", 6 | "clone": "node scripts/git-clone.js", 7 | "commit": "node scripts/git-commit.js", 8 | "pull": "node scripts/git-pull.js", 9 | "push": "node scripts/git-push.js" 10 | }, 11 | "dependencies": { 12 | "axios": "^0.24.0" 13 | }, 14 | "devDependencies": { 15 | "chalk": "^4.1.0", 16 | "command-exists": "^1.2.9", 17 | "dtfe": "^2.0.0", 18 | "shelljs": "^0.8.4" 19 | } 20 | } -------------------------------------------------------------------------------- /repos.json: -------------------------------------------------------------------------------- 1 | [ 2 | "fsharp", 3 | "jupyter", 4 | "coffeescript" 5 | ] -------------------------------------------------------------------------------- /scripts/change.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Utils to change files in all repositories. 3 | * 4 | * @author Carlos Abraham Hernandez (abranhe.com) 5 | */ 6 | 'use strict'; 7 | const fs = require('fs'); 8 | const path = require('path'); 9 | const exist = require('dtfe'); 10 | const chalk = require('chalk'); 11 | const shell = require('shelljs'); 12 | const repos = require('../repos.json'); 13 | 14 | const bufferFile = (file) => { 15 | return fs.readFileSync(path.join(__dirname, `../templates/${file}.txt`), { 16 | encoding: 'utf8', 17 | }); 18 | }; 19 | 20 | const files = [ 21 | { 22 | template: 'license', 23 | to: 'license', 24 | }, 25 | { 26 | template: 'readme', 27 | to: 'readme.md', 28 | }, 29 | { 30 | template: 'code-of-conduct', 31 | to: '.github/code-of-conduct.md', 32 | }, 33 | { 34 | template: 'contributing', 35 | to: '.github/contributing.md', 36 | }, 37 | { 38 | template: 'issue-template', 39 | to: '.github/issue-template.md', 40 | }, 41 | { 42 | template: 'pull-request-template', 43 | to: '.github/pull-request-template.md', 44 | }, 45 | ]; 46 | 47 | if (exist('./projects')) { 48 | shell.cd('./projects'); 49 | } 50 | 51 | try { 52 | repos.forEach((repo) => { 53 | // To create folders, and files individually 54 | // const global = `${repo}/src/.gitkeep`; 55 | 56 | // if (!exist(global)) { 57 | // shell.touch(global); 58 | // } 59 | 60 | if (exist(repo)) { 61 | files.forEach((file) => { 62 | const filename = `${repo}/${file.to}`; 63 | const data = bufferFile(file.template); 64 | 65 | fs.writeFile(filename, data, 'utf8', (err) => { 66 | if (err) { 67 | console.log(err); 68 | return; 69 | } 70 | }); 71 | }); 72 | } 73 | }); 74 | console.log(chalk.green('Done!')); 75 | } catch (_) { 76 | console.log(chalk.red('Something went wrong cloning the repos.')); 77 | } 78 | -------------------------------------------------------------------------------- /scripts/create.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This script automatically generates 4 | # a new documentation file. 5 | # 6 | # * docs/filename.md 7 | # 8 | # Usage: newdoc.sh [name] 9 | # e.g: newdoc.sh mergesort 10 | # 11 | # Author: Carlos Abraham Hernandez (abranhe.com) 12 | # 13 | 14 | help() { 15 | echo 16 | echo "Usage:" 17 | echo " $ newdoc.sh [name]" 18 | echo 19 | echo "Flags:" 20 | echo " -h --help Display help information" 21 | echo 22 | echo "Example:" 23 | echo " $ newdoc.sh mergesort" 24 | echo 25 | } 26 | 27 | shortHelp() { 28 | echo 29 | echo "Usage: newdoc.sh [name]" 30 | echo " e.g: newdoc.sh mergesort" 31 | echo 32 | echo "Type --help for more information" 33 | echo 34 | exit 0 35 | } 36 | 37 | if [ -z "${1}" ]; then 38 | shortHelp 39 | fi 40 | 41 | if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then 42 | help 43 | fi 44 | 45 | echo "Navigating to docs/ folder..." 46 | cd ../docs/ 47 | 48 | algorithm_name=$1 49 | 50 | # Capitalizing the fist letter https://stackoverflow.com/a/12487465/7602110 51 | algorithm_capital_case="$(tr '[:lower:]' '[:upper:]' <<< ${algorithm_name:0:1})${algorithm_name:1}" 52 | 53 | # Replacing characters in bash https://stackoverflow.com/a/5928254/7602110 54 | algorithm=${algorithm_capital_case//-/ } 55 | 56 | echo "Creating file..." 57 | cat >> $algorithm_name.md <<- EOF 58 | --- 59 | id: $algorithm_name 60 | title: $algorithm 61 | sidebar_label: $algorithm 62 | --- 63 | 64 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/$1.md) to add the content for this algorithm. 65 | EOF 66 | 67 | export GREEN='\033[0;32m' 68 | export NC='\033[0m' 69 | 70 | echo -e "The file ${GREEN}${algorithm_name}.md${NC} was created" -------------------------------------------------------------------------------- /scripts/docker-yarn-start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -eu 3 | 4 | port="${1:-30000}" 5 | dys_inside='inside the container' 6 | mnt_dir='/mnt' 7 | 8 | me="$(readlink -f "$0")" 9 | root_dir="$(dirname "$(dirname "$me")")" 10 | 11 | case "$port" in 12 | (-h|--help) 13 | printf '%s [-h|--help] []\n' "$0" 14 | ;; 15 | 16 | ("$dys_inside") 17 | cd "$root_dir/website" 18 | yarn 19 | yarn start 20 | ;; 21 | 22 | (*) 23 | cat >&2 < 6 | */ 7 | 'use strict'; 8 | const fs = require('fs'); 9 | 10 | const jsonData = '../website/sidebars.json'; 11 | const jsonObj = JSON.parse(fs.readFileSync(jsonData, 'utf8')); 12 | 13 | Object.keys(jsonObj.algorithms).forEach((key) => { 14 | const categories = jsonObj.algorithms[key]; 15 | for (algorithms in categories) { 16 | const algorithm = categories[algorithms]; 17 | const fileContent = `--- 18 | id: ${algorithm} 19 | title: ${algorithm.charAt(0).toUpperCase() + algorithm.slice(1).split('-').join(' ')} 20 | sidebar_label: ${algorithm.charAt(0).toUpperCase() + algorithm.slice(1).split('-').join(' ')} 21 | --- 22 | 23 | [Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/${algorithm}.md) to add the content for this algorithm.`; 24 | 25 | console.log(algorithm); 26 | fs.writeFile(`../docs/${algorithm}.md`, fileContent, (err) => { 27 | if (err) throw err; 28 | console.log('The file was succesfully saved!'); 29 | }); 30 | } 31 | }); 32 | -------------------------------------------------------------------------------- /scripts/git-add.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Git add all the repositories. 3 | * 4 | * @author Carlos Abraham Hernandez (abranhe.com) 5 | */ 6 | 'use strict'; 7 | const exist = require('dtfe'); 8 | const chalk = require('chalk'); 9 | const shell = require('shelljs'); 10 | const commandExists = require('command-exists'); 11 | const repos = require('../repos.json'); 12 | 13 | commandExists('git') 14 | .then(() => { 15 | if (!exist('./projects')) { 16 | shell.mkdir('./projects'); 17 | } 18 | 19 | shell.cd('./projects'); 20 | try { 21 | repos.forEach((repo) => { 22 | if (exist(repo)) { 23 | shell.cd(repo); 24 | shell.exec(`git add .`); 25 | shell.cd('../'); 26 | } 27 | }); 28 | } catch (_) { 29 | console.log(chalk.red('Something went wrong.')); 30 | } 31 | }) 32 | .catch((_) => { 33 | console.log(chalk.red(`'git' is required!`)); 34 | }); 35 | -------------------------------------------------------------------------------- /scripts/git-clone.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Clone all the repositories. 3 | * 4 | * @author Carlos Abraham Hernandez (abranhe.com) 5 | */ 6 | 'use strict'; 7 | const exist = require('dtfe'); 8 | const chalk = require('chalk'); 9 | const shell = require('shelljs'); 10 | const commandExists = require('command-exists'); 11 | const repos = require('../repos.json'); 12 | 13 | commandExists('git') 14 | .then(() => { 15 | if (!exist('./projects')) { 16 | shell.mkdir('./projects'); 17 | } 18 | 19 | shell.cd('./projects'); 20 | try { 21 | repos.forEach((repo) => { 22 | if (!exist(repo)) { 23 | shell.exec(`git clone https://github.com/allalgorithms/${repo}.git`); 24 | } 25 | }); 26 | } catch (_) { 27 | console.log(chalk.red('Something went wrong cloning the repos.')); 28 | } 29 | }) 30 | .catch((_) => { 31 | console.log(chalk.red(`'git' is required!`)); 32 | }); 33 | -------------------------------------------------------------------------------- /scripts/git-commit.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Git add all the repositories. 3 | * 4 | * @author Carlos Abraham Hernandez (abranhe.com) 5 | */ 6 | 'use strict'; 7 | const exist = require('dtfe'); 8 | const chalk = require('chalk'); 9 | const shell = require('shelljs'); 10 | const commandExists = require('command-exists'); 11 | const repos = require('../repos.json'); 12 | 13 | const args = process.argv.slice(2); 14 | const commitMessage = args[0] || 'refactofing!'; 15 | 16 | commandExists('git') 17 | .then(() => { 18 | if (!exist('./projects')) { 19 | shell.mkdir('./projects'); 20 | } 21 | 22 | shell.cd('./projects'); 23 | try { 24 | repos.forEach((repo) => { 25 | if (exist(repo)) { 26 | shell.cd(repo); 27 | shell.exec(`git ci -m '${commitMessage}'`); 28 | shell.cd('../'); 29 | } 30 | }); 31 | } catch (_) { 32 | console.log(chalk.red('Something went wrong.')); 33 | } 34 | }) 35 | .catch((_) => { 36 | console.log(chalk.red(`'git' is required!`)); 37 | }); 38 | -------------------------------------------------------------------------------- /scripts/git-pull.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Git add all the repositories. 3 | * 4 | * @author Carlos Abraham Hernandez (abranhe.com) 5 | */ 6 | 'use strict'; 7 | const exist = require('dtfe'); 8 | const chalk = require('chalk'); 9 | const shell = require('shelljs'); 10 | const commandExists = require('command-exists'); 11 | const repos = require('../repos.json'); 12 | 13 | commandExists('git') 14 | .then(() => { 15 | if (!exist('./projects')) { 16 | shell.mkdir('./projects'); 17 | } 18 | 19 | shell.cd('./projects'); 20 | try { 21 | repos.forEach((repo) => { 22 | if (exist(repo)) { 23 | shell.cd(repo); 24 | shell.exec(`git pull origin master`); 25 | shell.cd('../'); 26 | } 27 | }); 28 | } catch (_) { 29 | console.log(chalk.red('Something went wrong.')); 30 | } 31 | }) 32 | .catch((_) => { 33 | console.log(chalk.red(`'git' is required!`)); 34 | }); 35 | -------------------------------------------------------------------------------- /scripts/git-push.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Git add all the repositories. 3 | * 4 | * @author Carlos Abraham Hernandez (abranhe.com) 5 | */ 6 | 'use strict'; 7 | const exist = require('dtfe'); 8 | const chalk = require('chalk'); 9 | const shell = require('shelljs'); 10 | const commandExists = require('command-exists'); 11 | const repos = require('../repos.json'); 12 | 13 | commandExists('git') 14 | .then(() => { 15 | if (!exist('./projects')) { 16 | shell.mkdir('./projects'); 17 | } 18 | 19 | shell.cd('./projects'); 20 | try { 21 | repos.forEach((repo) => { 22 | if (exist(repo)) { 23 | shell.cd(repo); 24 | shell.exec(`git push origin master`); 25 | shell.cd('../'); 26 | } 27 | }); 28 | } catch (_) { 29 | console.log(chalk.red('Something went wrong.')); 30 | } 31 | }) 32 | .catch((_) => { 33 | console.log(chalk.red(`'git' is required!`)); 34 | }); 35 | -------------------------------------------------------------------------------- /scripts/repos.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Just to generate the `repos.json` file with all the repos. 3 | * 4 | * @author Carlos Abraham Hernandez (abranhe.com) 5 | */ 6 | 'use strict'; 7 | const fs = require('fs'); 8 | const axios = require('axios'); 9 | const chalk = require('chalk'); 10 | 11 | const getReposList = async () => { 12 | const endpoint = 'https://api.github.com/orgs/allalgorithms/repos'; 13 | 14 | return await axios 15 | .get(endpoint, { params: { per_page: 100 } }) 16 | .then((res) => res.data.map((repo) => repo.name)) 17 | .catch((_) => {}); 18 | }; 19 | 20 | (async () => { 21 | const repos = await getReposList(); 22 | const ignore = ['algorithms', '.github']; 23 | const data = repos.filter((repo) => !ignore.includes(repo)); 24 | 25 | fs.writeFile('repos.json', JSON.stringify(data, null, 4), 'utf8', (err) => { 26 | if (err) { 27 | console.log(chalk.red(`Error: ${err}`)); 28 | return; 29 | } 30 | 31 | console.log(chalk.green('Done!')); 32 | }); 33 | })(); 34 | -------------------------------------------------------------------------------- /templates/code-of-conduct.txt: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Attribution 36 | 37 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 38 | 39 | [homepage]: http://contributor-covenant.org 40 | [version]: http://contributor-covenant.org/version/1/4/ 41 | -------------------------------------------------------------------------------- /templates/contributing.txt: -------------------------------------------------------------------------------- 1 | ## Contributing 2 | 3 | > Please note that this project is released with a [Contributor Code of Conduct](code-of-conduct.md). By participating in this project you agree to abide by its terms. 4 | -------------------------------------------------------------------------------- /templates/issue-template.txt: -------------------------------------------------------------------------------- 1 | I am creating an issue because... 2 | -------------------------------------------------------------------------------- /templates/license.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 All Algorithms and its contributors (allalgorithms.com) 4 | Copyright (c) 2018 Carlos Abraham (abranhe.com) 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. -------------------------------------------------------------------------------- /templates/pull-request-template.txt: -------------------------------------------------------------------------------- 1 | I am creating a pull request for... 2 | 3 | - [ ] New algorithm 4 | - [ ] Update to an algorithm 5 | - [ ] Fix an error 6 | - [ ] Other - *Describe below* -------------------------------------------------------------------------------- /website/blog/2019-02-19-new-website.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: The All Algorithms new website is online! 3 | author: Abraham Hernandez 4 | authorURL: https://twitter.com/abranhe 5 | authorImageURL: https://avatars3.githubusercontent.com/u/21347264 6 | --- 7 | 8 | After a great year of opensourcing the new [allalgorithms.com](https://allalgorithms.com) is now up. -------------------------------------------------------------------------------- /website/core/Footer.js: -------------------------------------------------------------------------------- 1 | const React = require('react'); 2 | 3 | class Footer extends React.Component { 4 | docUrl(doc, language) { 5 | const baseUrl = this.props.config.baseUrl; 6 | const docsUrl = this.props.config.docsUrl; 7 | const docsPart = `${docsUrl ? `${docsUrl}/` : ''}`; 8 | const langPart = `${language ? `${language}/` : ''}`; 9 | return `${baseUrl}${docsPart}${langPart}${doc}`; 10 | } 11 | 12 | pageUrl(doc, language) { 13 | const baseUrl = this.props.config.baseUrl; 14 | return baseUrl + (language ? `${language}/` : '') + doc; 15 | } 16 | 17 | render() { 18 | const { config: siteConfig } = this.props; 19 | if ((siteConfig.repos || []).length === 0) return null; 20 | if ((siteConfig.libraries || []).length === 0) return null; 21 | if ((siteConfig.community || []).length === 0) return null; 22 | 23 | const repos = siteConfig.repos.filter((repo) => repo.pinned).map((repo) => ( 24 | 25 | {repo.language.charAt(0).toUpperCase() + repo.language.slice(1)} 26 | 27 | )); 28 | 29 | const librariesDocs = siteConfig.libraries.map((library) => ( 30 | 31 | {library.language.charAt(0).toUpperCase() + library.language.slice(1)} 32 | 33 | )); 34 | 35 | const communityPlatforms = siteConfig.community.filter((platform) => platform.pinned).map((platform) => ( 36 | 37 | {platform.name} 38 | 39 | )); 40 | 41 | return ( 42 | 82 | ); 83 | } 84 | } 85 | 86 | module.exports = Footer; 87 | -------------------------------------------------------------------------------- /website/data/algorithms.js: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | { 3 | category: 'Artificial Intelligence', 4 | algorithmList: [ 5 | 'Dbscan', 6 | 'Isodata', 7 | 'Linear regression', 8 | 'Logistic regression', 9 | 'Neutral style transfer', 10 | 'Sat', 11 | 'Tsp', 12 | 'A star', 13 | 'Artificial neutral network', 14 | 'Convolutional neutral network', 15 | 'Decision tree', 16 | 'Factorization machines', 17 | 'Gaussian mixtrue model', 18 | 'Gradient boostring trees', 19 | 'Hierachical clustering', 20 | 'Image processing', 21 | 'K nearest neighbors', 22 | 'K means', 23 | 'Minimax', 24 | 'Native bayes', 25 | 'Nearest sequence memory', 26 | 'Neutral network', 27 | 'Perceptron', 28 | 'Principal component analysis', 29 | 'Q learning', 30 | 'Random forest', 31 | 'Restricted boltzman machine' 32 | ] 33 | }, 34 | { 35 | category: 'Backtracking', 36 | algorithmList: [ 37 | 'Algorithm x', 38 | 'crossword puzzle', 39 | 'Knight tour', 40 | 'M coloring problem', 41 | 'N queen', 42 | 'Number of ways in maze', 43 | 'Partitions of set', 44 | 'Permutation of strings', 45 | 'Powerset', 46 | 'Rat in maze', 47 | 'Subset sum', 48 | 'Sudoku solve' 49 | ] 50 | }, 51 | { 52 | category: 'Bit Manipulation', 53 | algorithmList: [ 54 | 'Adding using bits', 55 | 'Bit divisor', 56 | 'Byte swapper', 57 | 'Convert numbers to binary', 58 | 'Count set bits', 59 | 'Flip bits', 60 | 'Hamming distace', 61 | 'Invert bit', 62 | 'Lonely integer', 63 | 'Magic number', 64 | 'Maximun xor value', 65 | 'Power of 2', 66 | 'Subset generation', 67 | 'Sum binary numbers', 68 | 'Sum equals xor', 69 | 'Thrice unique number', 70 | 'Twice unique number', 71 | 'Xor swap' 72 | ] 73 | }, 74 | { 75 | category: 'Cellular Automaton', 76 | algorithmList: [ 77 | 'Brians brain', 78 | 'Conways game of life', 79 | 'Elementary cellular automata', 80 | 'Generic algorithm', 81 | 'Langtons ant', 82 | 'Nobili cellular automata', 83 | 'Von neoumann cellular automata' 84 | ] 85 | }, 86 | { 87 | category: 'Computational Geometry', 88 | algorithmList: [ 89 | '2D Line intersection', 90 | '2D Separating Axis test', 91 | 'Area of polygon', 92 | 'Area of triangle', 93 | 'Axis aligned bounding box collision', 94 | 'Bresenham Line', 95 | 'Chans Algorithm', 96 | 'Cohen-Sutherland Lineclip', 97 | 'Distance between points', 98 | 'Graham Scan', 99 | 'Halfplane intersection', 100 | 'Jarvis March', 101 | 'Quickhull', 102 | 'Sphere tetrahedron intersection', 103 | 'Sutherland-Hodgman clipping' 104 | ] 105 | }, 106 | { 107 | category: 'Cryptography', 108 | algorithmList: [ 109 | 'Affine Cipher', 110 | 'Atbash Cipher', 111 | 'Autokey Cipher', 112 | 'Baconian Cipher', 113 | 'Caesar Cipher', 114 | 'Colummnar Cipher', 115 | 'Vigenere Cipher' 116 | ] 117 | }, 118 | { 119 | category: 'Data Structures', 120 | algorithmList: [ 'Bag', 'Hashes', 'Linked List', 'List', 'Queue', 'Stack', 'Tree' ] 121 | }, 122 | { 123 | category: 'Divide and Conquer', 124 | algorithmList: [ 125 | 'Strassen Matrix Manipulation', 126 | 'Closest Pair of Point', 127 | 'Inversion Count', 128 | 'Karatsuba Multiplication', 129 | 'Maximum Contiguous subsequence sum', 130 | 'Merge Sort using divide and conquer', 131 | 'Quick Sort using divide and conquer', 132 | 'Tournament Method to find min max', 133 | 'Warnock Algorithm', 134 | 'X Power Y' 135 | ] 136 | }, 137 | { 138 | category: 'Dynamic Programming', 139 | algorithmList: [ 'Array Median', 'Optima Binary Search Tree', 'Binomial Coefficient' ] 140 | }, 141 | { 142 | category: 'Gaming Theory', 143 | algorithmList: [ 'Nim Next Best Move Game', 'Nim Win Loss Game', 'Grundy Numbers Kayle Game' ] 144 | }, 145 | { 146 | category: 'Graphs', 147 | algorithmList: [ 'Bipartite Check', 'Adjacency Lists graphs representation', 'Astar Algorithm' ] 148 | }, 149 | { 150 | category: 'Greedy Algorithms', 151 | algorithmList: [ 'Activity Selection', 'Dijkstra Shortest Path', 'Egyptian Fraction' ] 152 | }, 153 | { 154 | category: 'Math', 155 | algorithmList: [ 156 | '2 Sum', 157 | 'Add Polynomials', 158 | 'Amicable Numbers', 159 | 'Armstrong Numbers', 160 | 'Automorphic Numbers', 161 | 'Average Stream Numbers', 162 | 'Babylonian Method', 163 | 'Binomial Coefficient', 164 | 'Catalan Number', 165 | 'Check is Square', 166 | 'Convolution', 167 | 'Coprime Numbers', 168 | 'Count Digits', 169 | 'Count Trailing Zeroes', 170 | 'Decoding of String', 171 | 'Delannoy Number', 172 | 'Derangements', 173 | 'DFA Division', 174 | 'Diophantine', 175 | 'Divided Differences', 176 | 'Euler Totient', 177 | 'Exponentiation Power', 178 | 'Factorial', 179 | 'Fast Fourier Transform', 180 | 'Fast inverse Square Root' 181 | ] 182 | }, 183 | { 184 | category: 'Networking', 185 | algorithmList: [ 'Packet Sniffer', 'Determine Endianess', 'Validate IP' ] 186 | }, 187 | { 188 | category: 'Numerical Analysis', 189 | algorithmList: [ 'Integral', 'Monte Carlo', 'Runge Kutt' ] 190 | }, 191 | { 192 | category: 'Online Challenges', 193 | algorithmList: [ 194 | 'Coderbyte', 195 | 'Code Chef', 196 | 'Code Eval', 197 | 'Hackerearth', 198 | 'Hackerrank', 199 | 'LeetCode', 200 | 'Project Euler', 201 | 'Rosalind', 202 | 'SPOJ', 203 | 'Top Coder' 204 | ] 205 | }, 206 | { 207 | category: 'Randomized Algorithms', 208 | algorithmList: [ 209 | 'Birthday Paradox', 210 | 'Karger Minimum Cut Algorithm', 211 | 'Kth Smallest Element Algorithm', 212 | 'Random from Stream', 213 | 'Random Node Linked list', 214 | 'Randomized Quicksort', 215 | 'Reservoir Sampling', 216 | 'Shuffle an Array' 217 | ] 218 | }, 219 | { 220 | category: 'Searches', 221 | algorithmList: [ 222 | 'Binary Search', 223 | 'Exponential Search', 224 | 'Fibonacci Search', 225 | 'Fuzzy Search', 226 | 'Interpolation Search', 227 | 'Jump Search', 228 | 'Linear Search', 229 | 'Ternay Search' 230 | ] 231 | }, 232 | { 233 | category: 'Selections', 234 | algorithmList: [ 'Median of Medians', 'Quick Select' ] 235 | }, 236 | { 237 | category: 'Sorting', 238 | algorithmList: [ 239 | 'Bead Sort', 240 | 'Bogo Sort', 241 | 'Bubble Sort', 242 | 'Bucket Sort', 243 | 'Circle Sort', 244 | 'Comb Sort', 245 | 'Counting Sort', 246 | 'Cycle Sort', 247 | 'Flash Sort', 248 | 'Gnome Sort', 249 | 'Heap Sort', 250 | 'Insertion Sort', 251 | 'Intro Sort', 252 | 'Median Sort', 253 | 'Merge Sort', 254 | 'Pigeonhole Sort', 255 | 'Quick Sort', 256 | 'Radix Sort', 257 | 'Selection Sort', 258 | 'Shaker Sort', 259 | 'Shell Sort', 260 | 'Sleep Sort', 261 | 'Stooge Sort', 262 | 'Topological Sort', 263 | 'Tree Sort' 264 | ] 265 | }, 266 | { 267 | category: 'Strings', 268 | algorithmList: [ 269 | 'Aho-Corasick Algorithm', 270 | 'Anagram Search', 271 | 'Arithmetic on large numbers', 272 | 'Boyer-Moore Algorithm', 273 | 'Finite Automata', 274 | 'Kasai Algorithm', 275 | 'Kmp Algorithm', 276 | 'Levenshtein Distance', 277 | 'Lipogram Checker' 278 | ] 279 | }, 280 | { 281 | category: 'No Category', 282 | algorithmList: [ 283 | 'Average', 284 | 'Biggest of n numbers', 285 | 'Biggest Suffix', 286 | 'Fifteen Puzzle', 287 | 'Jaccard Similarity', 288 | 'Jose Phus Problem', 289 | 'Lapindrom Checker', 290 | 'Leap Year', 291 | 'Magic Square', 292 | 'Majority Element', 293 | 'Minimum subarray size with degree', 294 | 'No operator addition', 295 | 'Paint fill', 296 | 'Split list', 297 | 'Tokenizer', 298 | 'Unique number' 299 | ] 300 | } 301 | ]; 302 | -------------------------------------------------------------------------------- /website/data/community.js: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | { 3 | name: 'Github', 4 | url: 'https://github.com/allalgorithms', 5 | pinned: true 6 | }, 7 | { 8 | name: 'Gitter', 9 | url: 'https://gitter.com/allalgorithms', 10 | pinned: true 11 | }, 12 | { 13 | name: 'Twitter', 14 | url: 'https://twitter.com/allalgorithms', 15 | pinned: true 16 | }, 17 | { 18 | name: 'Instagram', 19 | url: 'https://instagram.com/allalgorithms', 20 | pinned: true 21 | }, 22 | { 23 | name: 'Facebook', 24 | url: 'https://facebook.com/allalgorithms', 25 | pinned: true 26 | }, 27 | { 28 | name: 'Stackoverflow', 29 | url: 'https://stackoverflow.com/questions/tagged/algorithms', 30 | pinned: false 31 | }, 32 | ] -------------------------------------------------------------------------------- /website/data/languages.js: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | { 3 | language: 'cpp', 4 | logo: 'https://cdn.jsdelivr.net/npm/programming-languages-logos@0.0.2/src/cpp/cpp.svg', 5 | }, 6 | { 7 | language: 'python', 8 | logo: 'https://cdn.jsdelivr.net/npm/programming-languages-logos@0.0.2/src/python/python.svg', 9 | }, 10 | { 11 | language: 'java', 12 | logo: 'https://cdn.jsdelivr.net/npm/programming-languages-logos@0.0.2/src/java/java.svg', 13 | }, 14 | { 15 | language: 'javascript', 16 | logo: 'https://cdn.jsdelivr.net/npm/programming-languages-logos@0.0.2/src/javascript/javascript.svg', 17 | }, 18 | ]; -------------------------------------------------------------------------------- /website/data/libraries.js: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | { 3 | language: 'python', 4 | repo: 'https://github.com/abranhe/allalgorithms-java', 5 | url: 'https://python.allalgorithms.com', 6 | author: 'abranhe', 7 | languageLogo: 'https://cdn.jsdelivr.net/npm/programming-languages-logos@0.0.2/src/python/python.svg', 8 | dollar: '$', 9 | installation: 'install allalgorithms', 10 | cmd: 'pip', 11 | registry: 'PIP', 12 | registryLogo: 'pip.png', 13 | registryURL: 'https://pypi.org', 14 | navigateToPkg: 'project', 15 | pinned: true, 16 | }, 17 | { 18 | language: 'java', 19 | repo: 'https://github.com/abranhe/allalgorithms-java', 20 | url: 'https://java.allalgorithms.com', 21 | author: 'abranhe', 22 | languageLogo: 'https://cdn.jsdelivr.net/npm/programming-languages-logos@0.0.2/src/java/java.svg', 23 | installation: ` 24 | 25 | com.abranhe.allalgorithms 26 | allalgorithms 27 | 0.0.1 28 | 29 | `, 30 | registry: 'Maven', 31 | registryLogo: 'maven.png', 32 | registryURL: 'https://search.maven.org', 33 | navigateToPkg: 'artifact/com.abranhe', 34 | pinned: true 35 | }, 36 | { 37 | language: 'javascript', 38 | repo: 'https://github.com/abranhe/allalgorithms-js', 39 | url: 'https://js.allalgorithms.com', 40 | author: 'abranhe', 41 | dollar: '$', 42 | installation: 'install allalgorithms', 43 | cmd: 'npm', 44 | languageLogo: 'https://cdn.jsdelivr.net/npm/programming-languages-logos@0.0.2/src/javascript/javascript.svg', 45 | registry: 'NPM', 46 | registryLogo: 'npm.png', 47 | registryURL: 'https://npmjs.org', 48 | navigateToPkg: 'package', 49 | pinned: true 50 | }, 51 | ]; -------------------------------------------------------------------------------- /website/data/repos.js: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | { 3 | language: 'c', 4 | image: 'https://img.shields.io/github/stars/allalgorithms/c.svg?style=social', 5 | link: 'https://github.com/allalgorithms/c', 6 | pinned: false, 7 | }, 8 | { 9 | language: 'c++', 10 | image: 'https://img.shields.io/github/stars/allalgorithms/cpp.svg?style=social', 11 | link: 'https://github.com/allalgorithms/cpp', 12 | pinned: true, 13 | }, 14 | { 15 | language: 'java', 16 | image: 'https://img.shields.io/github/stars/allalgorithms/java.svg?style=social', 17 | link: 'https://github.com/allalgorithms/java', 18 | pinned: true, 19 | }, 20 | { 21 | language: 'javascript', 22 | image: 'https://img.shields.io/github/stars/allalgorithms/javascript.svg?style=social', 23 | link: 'https://github.com/allalgorithms/javascript', 24 | pinned: true, 25 | }, 26 | { 27 | language: 'ruby', 28 | image: 'https://img.shields.io/github/stars/allalgorithms/ruby.svg?style=social', 29 | link: 'https://github.com/allalgorithms/ruby', 30 | pinned: true, 31 | }, 32 | { 33 | language: 'go', 34 | image: 'https://img.shields.io/github/stars/allalgorithms/go.svg?style=social', 35 | link: 'https://github.com/allalgorithms/go', 36 | pinned: true, 37 | }, 38 | ]; -------------------------------------------------------------------------------- /website/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "examples": "docusaurus-examples", 4 | "start": "docusaurus-start", 5 | "build": "docusaurus-build", 6 | "publish-gh-pages": "docusaurus-publish", 7 | "write-translations": "docusaurus-write-translations", 8 | "version": "docusaurus-version", 9 | "rename-version": "docusaurus-rename-version" 10 | }, 11 | "devDependencies": { 12 | "docusaurus": "^1.6.2" 13 | }, 14 | "dependencies": { 15 | "axios": "^0.18.0", 16 | "typed.js": "^2.0.10" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /website/pages/en/categories.js: -------------------------------------------------------------------------------- 1 | const React = require('react'); 2 | const CompLibrary = require('../../core/CompLibrary.js'); 3 | 4 | class Categories extends React.Component { 5 | 6 | docUrl(doc, language) { 7 | const baseUrl = this.props.config.baseUrl; 8 | const docsUrl = this.props.config.docsUrl; 9 | const docsPart = `${docsUrl ? `${docsUrl}/` : ''}`; 10 | const langPart = `${language ? `${language}/` : ''}`; 11 | return `${baseUrl}${docsPart}${langPart}${doc}`; 12 | }; 13 | 14 | render() { 15 | const { config: siteConfig } = this.props; 16 | if ((siteConfig.algorithms || []).length === 0) { 17 | return null; 18 | } 19 | 20 | const algorithmNameToId = (name) => { 21 | return (name.charAt(0).toLowerCase() + name.slice(1)).split(' ').join('-'); 22 | }; 23 | 24 | const categories = siteConfig.algorithms.map((categoriy) => ( 25 |
26 | {categoriy.category} 27 |
    28 | {categoriy.algorithmList.map((algoritm) => ( 29 |
  • 30 | {algoritm} 31 |
  • 32 | ))} 33 |
34 |
35 | )); 36 | 37 | return ( 38 |
39 |
40 |
41 |

Categories of Algorithms

42 |

The All ▲lgorithms Project Structure Categories

43 |
44 | {categories} 45 |
46 |
47 | ); 48 | } 49 | } 50 | 51 | module.exports = Categories; 52 | -------------------------------------------------------------------------------- /website/pages/en/help.js: -------------------------------------------------------------------------------- 1 | const React = require('react'); 2 | 3 | const CompLibrary = require('../../core/CompLibrary.js'); 4 | 5 | const Container = CompLibrary.Container; 6 | const GridBlock = CompLibrary.GridBlock; 7 | 8 | function Help(props) { 9 | const {config: siteConfig, language = ''} = props; 10 | const {baseUrl, docsUrl} = siteConfig; 11 | const docsPart = `${docsUrl ? `${docsUrl}/` : ''}`; 12 | const langPart = `${language ? `${language}/` : ''}`; 13 | const docUrl = doc => `${baseUrl}${docsPart}${langPart}${doc}`; 14 | 15 | const supportLinks = [ 16 | { 17 | content: `Learn more using the [documentation on this site.](${docUrl( 18 | 'doc1.html', 19 | )})`, 20 | title: 'Browse Docs', 21 | }, 22 | { 23 | content: 'Ask questions about the documentation and project', 24 | title: 'Join the community', 25 | }, 26 | { 27 | content: "Find out what's new with this project", 28 | title: 'Stay up to date', 29 | }, 30 | ]; 31 | 32 | return ( 33 |
34 | 35 |
36 |
37 |

Need help?

38 |
39 |

This project is maintained by a dedicated group of people.

40 | 41 |
42 |
43 |
44 | ); 45 | } 46 | 47 | module.exports = Help; 48 | -------------------------------------------------------------------------------- /website/pages/en/index.js: -------------------------------------------------------------------------------- 1 | const React = require('react'); 2 | 3 | const CompLibrary = require('../../core/CompLibrary.js'); 4 | 5 | const MarkdownBlock = CompLibrary.MarkdownBlock; /* Used to read markdown */ 6 | const Container = CompLibrary.Container; 7 | const GridBlock = CompLibrary.GridBlock; 8 | 9 | class HomeSplash extends React.Component { 10 | render() { 11 | const {siteConfig, language = ''} = this.props; 12 | const {baseUrl, docsUrl} = siteConfig; 13 | const docsPart = `${docsUrl ? `${docsUrl}/` : ''}`; 14 | const langPart = `${language ? `${language}/` : ''}`; 15 | const docUrl = doc => `${baseUrl}${docsPart}${langPart}${doc}`; 16 | 17 | const SplashContainer = props => ( 18 |
19 |
20 |
{props.children}
21 |
22 |
23 | ); 24 | 25 | const Logo = props => ( 26 |
27 | Project Logo 28 |
29 | ); 30 | 31 | const ProjectTitle = () => ( 32 |

33 | {siteConfig.title} 34 | {siteConfig.tagline} 35 |

36 | ); 37 | 38 | const PromoSection = props => ( 39 |
40 |
41 |
{props.children}
42 |
43 |
44 | ); 45 | 46 | const Button = props => ( 47 | 52 | ); 53 | 54 | return ( 55 | 56 | 57 |
58 | 59 | 60 | 61 | 62 | 63 |
64 |
65 | ); 66 | } 67 | } 68 | 69 | class Index extends React.Component { 70 | render() { 71 | const {config: siteConfig, language = ''} = this.props; 72 | const {baseUrl} = siteConfig; 73 | 74 | const Block = props => ( 75 | 79 | 84 | 85 | ); 86 | 87 | const FeatureCallout = () => ( 88 |
91 |

Join the Huge Collection of Algorithms

92 | {/* These are features of this project */} 93 |
94 | ); 95 | 96 | return ( 97 |
98 | 99 |
100 | 101 |
102 |
103 | ); 104 | } 105 | } 106 | 107 | module.exports = Index; 108 | -------------------------------------------------------------------------------- /website/pages/en/libraries.js: -------------------------------------------------------------------------------- 1 | const React = require('react'); 2 | 3 | class Categories extends React.Component { 4 | docUrl(doc, language) { 5 | const baseUrl = this.props.config.baseUrl; 6 | const docsUrl = this.props.config.docsUrl; 7 | const docsPart = `${docsUrl ? `${docsUrl}/` : ''}`; 8 | const langPart = `${language ? `${language}/` : ''}`; 9 | return `${baseUrl}${docsPart}${langPart}${doc}`; 10 | } 11 | 12 | render() { 13 | const { config: siteConfig } = this.props; 14 | if ((siteConfig.algorithms || []).length === 0) { 15 | return null; 16 | } 17 | 18 | const categories = siteConfig.libraries.map((library) => ( 19 |
20 |

21 | {' '} 22 | {library.language.charAt(0).toUpperCase() + library.language.slice(1)} 23 |

24 | The All ▲lgorithms {library.language} library can be installed using{' '} 25 | {library.registry} 26 |
27 |
28 |
29 |
30 |             {library.dollar} {library.cmd}{' '}
31 |             {library.installation}
32 |           
33 |
34 |
35 | )); 36 | return ( 37 |
38 |
39 |
40 |

All ▲lgorithms Libraries

41 |

Collection of the All ▲lgorithms libraries in multiple programming languages

42 |
43 | {categories} 44 |
45 |
46 | ); 47 | } 48 | } 49 | 50 | module.exports = Categories; 51 | -------------------------------------------------------------------------------- /website/readme.md: -------------------------------------------------------------------------------- 1 | This website was created with [Docusaurus](https://docusaurus.io/). 2 | 3 | # What's In This Document 4 | 5 | * [Get Started in 5 Minutes](#get-started-in-5-minutes) 6 | * [Directory Structure](#directory-structure) 7 | * [Editing Content](#editing-content) 8 | * [Adding Content](#adding-content) 9 | * [Full Documentation](#full-documentation) 10 | 11 | # Get Started in 5 Minutes 12 | 13 | 1. Make sure all the dependencies for the website are installed: 14 | 15 | ```sh 16 | # Install dependencies 17 | $ yarn 18 | ``` 19 | 2. Run your dev server: 20 | 21 | ```sh 22 | # Start the site 23 | $ yarn start 24 | ``` 25 | 26 | ## Directory Structure 27 | 28 | Your project file structure should look something like this 29 | 30 | ``` 31 | my-docusaurus/ 32 | docs/ 33 | doc-1.md 34 | doc-2.md 35 | doc-3.md 36 | website/ 37 | blog/ 38 | 2016-3-11-oldest-post.md 39 | 2017-10-24-newest-post.md 40 | core/ 41 | node_modules/ 42 | pages/ 43 | static/ 44 | css/ 45 | img/ 46 | package.json 47 | sidebar.json 48 | siteConfig.js 49 | ``` 50 | 51 | # Editing Content 52 | 53 | ## Editing an existing docs page 54 | 55 | Edit docs by navigating to `docs/` and editing the corresponding document: 56 | 57 | `docs/doc-to-be-edited.md` 58 | 59 | ```markdown 60 | --- 61 | id: page-needs-edit 62 | title: This Doc Needs To Be Edited 63 | --- 64 | 65 | Edit me... 66 | ``` 67 | 68 | For more information about docs, click [here](https://docusaurus.io/docs/en/navigation) 69 | 70 | ## Editing an existing blog post 71 | 72 | Edit blog posts by navigating to `website/blog` and editing the corresponding post: 73 | 74 | `website/blog/post-to-be-edited.md` 75 | ```markdown 76 | --- 77 | id: post-needs-edit 78 | title: This Blog Post Needs To Be Edited 79 | --- 80 | 81 | Edit me... 82 | ``` 83 | 84 | For more information about blog posts, click [here](https://docusaurus.io/docs/en/adding-blog) 85 | 86 | # Adding Content 87 | 88 | ## Adding a new docs page to an existing sidebar 89 | 90 | 1. Create the doc as a new markdown file in `/docs`, example `docs/newly-created-doc.md`: 91 | 92 | ```md 93 | --- 94 | id: newly-created-doc 95 | title: This Doc Needs To Be Edited 96 | --- 97 | 98 | My new content here.. 99 | ``` 100 | 101 | 1. Refer to that doc's ID in an existing sidebar in `website/sidebar.json`: 102 | 103 | ```javascript 104 | // Add newly-created-doc to the Getting Started category of docs 105 | { 106 | "docs": { 107 | "Getting Started": [ 108 | "quick-start", 109 | "newly-created-doc" // new doc here 110 | ], 111 | ... 112 | }, 113 | ... 114 | } 115 | ``` 116 | 117 | For more information about adding new docs, click [here](https://docusaurus.io/docs/en/navigation) 118 | 119 | ## Adding a new blog post 120 | 121 | 1. Make sure there is a header link to your blog in `website/siteConfig.js`: 122 | 123 | `website/siteConfig.js` 124 | ```javascript 125 | headerLinks: [ 126 | ... 127 | { blog: true, label: 'Blog' }, 128 | ... 129 | ] 130 | ``` 131 | 132 | 2. Create the blog post with the format `YYYY-MM-DD-My-Blog-Post-Title.md` in `website/blog`: 133 | 134 | `website/blog/2018-05-21-New-Blog-Post.md` 135 | 136 | ```markdown 137 | --- 138 | author: Frank Li 139 | authorURL: https://twitter.com/foobarbaz 140 | authorFBID: 503283835 141 | title: New Blog Post 142 | --- 143 | 144 | Lorem Ipsum... 145 | ``` 146 | 147 | For more information about blog posts, click [here](https://docusaurus.io/docs/en/adding-blog) 148 | 149 | ## Adding items to your site's top navigation bar 150 | 151 | 1. Add links to docs, custom pages or external links by editing the headerLinks field of `website/siteConfig.js`: 152 | 153 | `website/siteConfig.js` 154 | ```javascript 155 | { 156 | headerLinks: [ 157 | ... 158 | /* you can add docs */ 159 | { doc: 'my-examples', label: 'Examples' }, 160 | /* you can add custom pages */ 161 | { page: 'help', label: 'Help' }, 162 | /* you can add external links */ 163 | { href: 'https://github.com/facebook/Docusaurus', label: 'GitHub' }, 164 | ... 165 | ], 166 | ... 167 | } 168 | ``` 169 | 170 | For more information about the navigation bar, click [here](https://docusaurus.io/docs/en/navigation) 171 | 172 | ## Adding custom pages 173 | 174 | 1. Docusaurus uses React components to build pages. The components are saved as .js files in `website/pages/en`: 175 | 1. If you want your page to show up in your navigation header, you will need to update `website/siteConfig.js` to add to the `headerLinks` element: 176 | 177 | `website/siteConfig.js` 178 | ```javascript 179 | { 180 | headerLinks: [ 181 | ... 182 | { page: 'my-new-custom-page', label: 'My New Custom Page' }, 183 | ... 184 | ], 185 | ... 186 | } 187 | ``` 188 | 189 | For more information about custom pages, click [here](https://docusaurus.io/docs/en/custom-pages). 190 | 191 | # Full Documentation 192 | 193 | Full documentation can be found on the [website](https://docusaurus.io/). 194 | -------------------------------------------------------------------------------- /website/sidebars.json: -------------------------------------------------------------------------------- 1 | { 2 | "algorithms": { 3 | "Artificial Intelligence": [ 4 | "dbscan", 5 | "isodata", 6 | "linear-regression", 7 | "logistic-regression", 8 | "neutral-style-transfer", 9 | "sat", 10 | "tsp", 11 | "a-star", 12 | "artificial-neutral-network", 13 | "convolutional-neutral-network", 14 | "decision-tree", 15 | "factorization-machines", 16 | "gaussian-mixtrue-model", 17 | "gradient-boostring-trees", 18 | "hierachical-clustering", 19 | "image-processing", 20 | "k-nearest-neighbors", 21 | "k-means", 22 | "minimax", 23 | "native-bayes", 24 | "nearest-sequence-memory", 25 | "neutral-network", 26 | "perceptron", 27 | "principal-component-analysis", 28 | "q-learning", 29 | "random-forest", 30 | "restricted-boltzman-machine" 31 | ], 32 | "Backtracking": [ 33 | "algorithm-x", 34 | "crossword-puzzle", 35 | "knight-tour", 36 | "m-coloring-problem", 37 | "n-queen", 38 | "number-of-ways-in-maze", 39 | "partitions-of-set", 40 | "permutation-of-strings", 41 | "powerset", 42 | "rat-in-maze", 43 | "subset-sum", 44 | "sudoku-solve" 45 | ], 46 | "Bit manipulation": [ 47 | "adding-using-bits", 48 | "bit-divisor", 49 | "byte-swapper", 50 | "convert-numbers-to-binary", 51 | "count-set-bits", 52 | "flip-bits", 53 | "hamming-distace", 54 | "invert-bit", 55 | "lonely-integer", 56 | "magic-number", 57 | "maximun-xor-value", 58 | "power-of-2", 59 | "subset-generation", 60 | "sum-binary-numbers", 61 | "sum-equals-xor", 62 | "thrice-unique-number", 63 | "twice-unique-number", 64 | "xor-swap" 65 | ], 66 | "Cellular automaton": [ 67 | "brians-brain", 68 | "conways-game-of-life", 69 | "elementary-cellular-automata", 70 | "generic-algorithm", 71 | "langtons-ant", 72 | "nobili-cellular-automata", 73 | "von-neoumann-cellular-automata" 74 | ], 75 | "Computational geometry": [ 76 | "2d-line-intersection", 77 | "2d-separating-axis-test", 78 | "area-of-polygon", 79 | "area-of-triangle", 80 | "axis-aligned-bounding-box-collision", 81 | "bresenham-line", 82 | "chans-algorithm", 83 | "cohen-sutherland-lineclip", 84 | "distance-between-points", 85 | "graham-scan", 86 | "halfplane-intersection", 87 | "jarvis-march", 88 | "quickhull", 89 | "sphere-tetrahedron-intersection", 90 | "sutherland-hodgman-clipping" 91 | ], 92 | "Cryptography": [ 93 | "affine-cipher", 94 | "atbash-cipher", 95 | "autokey-cipher", 96 | "baconian-cipher", 97 | "caesar-cipher", 98 | "colummnar-cipher", 99 | "vigenere-cipher" 100 | ], 101 | "Data structures": [ 102 | "bag", "hashes", "linked-list", "list", "queue", "stack", "tree" 103 | ], 104 | "Divide and conquer": [ 105 | "strassen-matrix-manipulation", 106 | "closest-pair-of-point", 107 | "inversion-count", 108 | "karatsuba-multiplication", 109 | "maximum-contiguous-subsequence-sum", 110 | "merge-sort-using-divide-and-conquer", 111 | "quick-sort-using-divide-and-conquer", 112 | "tournament-method-to-find-min-max", 113 | "warnock-algorithm", 114 | "x-power-y" 115 | ], 116 | "Dynamic programming": [ 117 | "array-median", "optima-binary-search-tree", "binomial-coefficient" 118 | ], 119 | "Gaming theory": [ 120 | "nim-next-best-move-game", "nim-win-loss-game", "grundy-numbers-kayle-game" 121 | ], 122 | "Graphs": [ 123 | "bipartite-check", "adjacency-lists-graphs-representation", "astar-algorithm" 124 | ], 125 | "Greedy algorithms": [ 126 | "activity-selection", "dijkstra-shortest-path", "egyptian-fraction" 127 | ], 128 | "Math": [ 129 | "2-sum", 130 | "add-polynomials", 131 | "amicable-numbers", 132 | "armstrong-numbers", 133 | "automorphic-numbers", 134 | "average-stream-numbers", 135 | "babylonian-method", 136 | "binomial-coefficient", 137 | "catalan-number", 138 | "check-is-square", 139 | "convolution", 140 | "coprime-numbers", 141 | "count-digits", 142 | "count-trailing-zeroes", 143 | "decoding-of-string", 144 | "delannoy-number", 145 | "derangements", 146 | "dfa-division", 147 | "diophantine", 148 | "divided-differences", 149 | "euler-totient", 150 | "exponentiation-power", 151 | "factorial", 152 | "fast-fourier-transform", 153 | "fast-inverse-square-root" 154 | ], 155 | "Networking": [ 156 | "packet-sniffer", "determine-endianess", "validate-ip" 157 | ], 158 | "Numerical analysis": [ 159 | "integral", "monte-carlo", "runge-kutt" 160 | ], 161 | "Randomized algorithms": [ 162 | "birthday-paradox", 163 | "karger-minimum-cut-algorithm", 164 | "kth-smallest-element-algorithm", 165 | "random-from-stream", 166 | "random-node-linked-list", 167 | "randomized-quicksort", 168 | "reservoir-sampling", 169 | "shuffle-an-array" 170 | ], 171 | "Searches": [ 172 | "binary-search", 173 | "exponential-search", 174 | "fibonacci-search", 175 | "fuzzy-search", 176 | "interpolation-search", 177 | "jump-search", 178 | "linear-search", 179 | "ternay-search" 180 | ], 181 | "Selections algorithms": [ 182 | "median-of-medians", "quick-select" 183 | ], 184 | "Sorting": [ 185 | "bead-sort", 186 | "bogo-sort", 187 | "bubble-sort", 188 | "bucket-sort", 189 | "circle-sort", 190 | "comb-sort", 191 | "counting-sort", 192 | "cycle-sort", 193 | "flash-sort", 194 | "gnome-sort", 195 | "heap-sort", 196 | "insertion-sort", 197 | "intro-sort", 198 | "median-sort", 199 | "merge-sort", 200 | "pigeonhole-sort", 201 | "quick-sort", 202 | "radix-sort", 203 | "selection-sort", 204 | "shaker-sort", 205 | "shell-sort", 206 | "sleep-sort", 207 | "stooge-sort", 208 | "topological-sort", 209 | "tree-sort" 210 | ], 211 | "Strings": [ 212 | "aho-corasick-algorithm", 213 | "anagram-search", 214 | "arithmetic-on-large-numbers", 215 | "boyer-moore-algorithm", 216 | "finite-automata", 217 | "kasai-algorithm", 218 | "kmp-algorithm", 219 | "levenshtein-distance", 220 | "lipogram-checker" 221 | ], 222 | "Online challenges": [ 223 | "coderbyte", 224 | "code-chef", 225 | "code-eval", 226 | "hackerearth", 227 | "hackerrank", 228 | "leetcode", 229 | "project-euler", 230 | "rosalind", 231 | "spoj", 232 | "top-coder" 233 | ], 234 | "No category": [ 235 | "average", 236 | "biggest-of-n-numbers", 237 | "biggest-suffix", 238 | "fifteen-puzzle", 239 | "jaccard-similarity", 240 | "jose-phus-problem", 241 | "lapindrom-checker", 242 | "leap-year", 243 | "magic-square", 244 | "majority-element", 245 | "minimum-subarray-size-with-degree", 246 | "no-operator-addition", 247 | "paint-fill", 248 | "split-list", 249 | "tokenizer", 250 | "unique-number" 251 | ] 252 | } 253 | } 254 | -------------------------------------------------------------------------------- /website/siteConfig.js: -------------------------------------------------------------------------------- 1 | const repos = require('./data/repos'); 2 | const libraries = require('./data/libraries'); 3 | const community = require('./data/community'); 4 | const algorithms = require('./data/algorithms'); 5 | const languages = require('./data/languages'); 6 | 7 | const siteConfig = { 8 | title: 'All ▲lgorithms', 9 | tagline: 'Making algorithms easier for everyone', 10 | url: 'https://allalgorithms.com', 11 | baseUrl: '/', 12 | 13 | projectName: 'algorithms', 14 | organizationName: 'AllAlgorithms', 15 | 16 | headerLinks: [ 17 | {doc: 'dbscan', label: 'Algorithms'}, 18 | {page: 'categories', label: 'Categories'}, 19 | {page: 'libraries', label: 'Libraries'}, 20 | {blog: true, label: 'Blog'}, 21 | { search: true } 22 | ], 23 | 24 | languages, 25 | repos, 26 | libraries, 27 | community, 28 | algorithms, 29 | 30 | /* path to images for header/footer */ 31 | headerIcon: 'img/algorithms-white.svg', 32 | footerIcon: 'img/algorithms-white.png', 33 | favicon: 'img/agorithms.png', 34 | 35 | /* Colors for website */ 36 | colors: { 37 | primaryColor: '#61231d', 38 | secondaryColor: '#61231d', 39 | }, 40 | 41 | copyright: `Copyright © ${new Date().getFullYear()} The All ▲lgorithms Project.`, 42 | 43 | highlight: { 44 | theme: 'default', 45 | }, 46 | 47 | scripts: ['https://buttons.github.io/buttons.js'], 48 | 49 | // On page navigation for the current documentation page. 50 | onPageNav: 'separate', 51 | // No .html extensions for paths. 52 | cleanUrl: true, 53 | 54 | // Open Graph and Twitter card images. 55 | ogImage: 'img/algorithms-white.png', 56 | twitterImage: 'alalgorithms-white.png', 57 | 58 | // Show documentation's last contributor's name. 59 | enableUpdateBy: true, 60 | 61 | // Show documentation's last update time. 62 | enableUpdateTime: true, 63 | 64 | repoUrl: 'https://github.com/allalgorithms/algorithms', 65 | githubUrl: 'https://github.com/allalgorithms/', 66 | 67 | algolia: { 68 | apiKey: '033c9494cdabd6c7380e930bd8969da0', 69 | indexName: 'allalgorithms', 70 | algoliaOptions: {} , 71 | placeholder: 'Search' 72 | }, 73 | }; 74 | 75 | module.exports = siteConfig; 76 | -------------------------------------------------------------------------------- /website/static/css/custom.css: -------------------------------------------------------------------------------- 1 | @media only screen and (min-device-width: 360px) and (max-device-width: 736px) { 2 | } 3 | 4 | @media only screen and (min-width: 1024px) { 5 | } 6 | 7 | @media only screen and (max-width: 1023px) { 8 | } 9 | 10 | @media only screen and (min-width: 1400px) { 11 | } 12 | 13 | @media only screen and (min-width: 1500px) { 14 | } 15 | 16 | .footerSection { 17 | background: #470d07 !important; 18 | } 19 | 20 | ul.categories { 21 | list-style-type: none; 22 | } 23 | 24 | details[open] summary ~ * { 25 | animation: sweep .5s ease-in-out; 26 | } 27 | 28 | @keyframes sweep { 29 | 0% {opacity: 0; margin-left: -10px} 30 | 100% {opacity: 1; margin-left: 0px} 31 | } 32 | 33 | 34 | summary::-webkit-details-marker { 35 | display: none 36 | } 37 | 38 | /* http://html5doctor.com/the-details-and-summary-elements/#styling */ 39 | summary::before { 40 | content: "+"; 41 | font-size: 1.5em; 42 | font-weight: bold; 43 | margin: -5px 10px 0 0; 44 | padding: 0; 45 | color: #61231d; 46 | } 47 | details[open] summary:before { 48 | content: "-"; 49 | } 50 | 51 | 52 | .fake-term { 53 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; 54 | background: #1d1d1d; 55 | color: white; 56 | padding: 25px; 57 | margin: 0 auto; 58 | border-radius: 5px; 59 | box-shadow: 10px 8px 17px -9px rgba(29, 29, 29, 0.6); 60 | } 61 | .fake-term:not(.help-menu) { 62 | width: 420px; 63 | height: auto; 64 | } 65 | .fake-term span.dollar { 66 | color: #00ff62; 67 | } 68 | .fake-term span.cmd { 69 | color: #cbffad; 70 | } 71 | .fake-term span.comment { 72 | color: lightgray; 73 | opacity: 0.5; 74 | } 75 | -------------------------------------------------------------------------------- /website/static/img/algorithms-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllAlgorithms/algorithms/e04b70f3c20890d1ab8a8593468e8ffd00e1e4f4/website/static/img/algorithms-white.png -------------------------------------------------------------------------------- /website/static/img/algorithms-white.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Group 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /website/static/img/algorithms.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllAlgorithms/algorithms/e04b70f3c20890d1ab8a8593468e8ffd00e1e4f4/website/static/img/algorithms.png -------------------------------------------------------------------------------- /website/static/img/algorithms.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | allalgorithms 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | lgorithms 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /website/static/img/allalgorithms-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllAlgorithms/algorithms/e04b70f3c20890d1ab8a8593468e8ffd00e1e4f4/website/static/img/allalgorithms-white.png -------------------------------------------------------------------------------- /website/static/img/screenshot-2019-may-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllAlgorithms/algorithms/e04b70f3c20890d1ab8a8593468e8ffd00e1e4f4/website/static/img/screenshot-2019-may-6.png -------------------------------------------------------------------------------- /website/static/img/tryhtml.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllAlgorithms/algorithms/e04b70f3c20890d1ab8a8593468e8ffd00e1e4f4/website/static/img/tryhtml.png --------------------------------------------------------------------------------