Skip to content

Commit

Permalink
A few small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nbro committed Oct 5, 2017
1 parent aa301e5 commit 29688f8
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 62 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ ands/algorithms/graphs/
ands/algorithms/unclassified/
/ands/algorithms/math/combinatorics/
/ands/algorithms/math/
ands/algorithms/numerical/neville.py
ands/algorithms/dp/previous_larger_element.py

*.eggx
*.py[cod]
Expand Down
47 changes: 35 additions & 12 deletions ands/algorithms/README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,41 @@
# Algorithms

I would like to include algorithms regarding the following topics:

- Linear algebra (Guassian, RREF, Jacobi, determinants, ...)
- Numerical computing (PDE, ODE, Poisson, Social Networks, Graph Partioning, Conjugate Gradient, Page Rank, Horner...)
- Linear programming
- Artificial intelligence (Swarm intelligence, A<sup>*</sup>, Genetic algorithms, ...)
- Geometrical algorithms (Convex hull, ...)
- Generation of random numbers
- Error correction codes
- CNF, DNF, 2-satisfiability
- Equations (quadratic, cubic and quartic equations formulas ...)
- Heuristics to NP-complete problems
Algorithms I am particularly interested in are:

- Neville's algorithm (for polynomial interpolation)
- Jacobi
- PageRank
- PowerMethod
- Graph partitioning algorithms
- Conjugate gradient (gradient descent and ascent)
- Cuthill–McKee algorithm
- Gauss-Newton algorithm
- Gauss–Seidel method
- Guassian elimination
- Guassian elimination with pivoting
- LU decomposition (or factorization)
- Cholesky decomposition (for symmetric positive definite matrices)
- Bisection method
- Fixed-point iteration
- Secant method
- A<sup>*</sup>
- MCTS
- Christofides algorithm
- Fisher–Yates shuffle
- Alpha-beta pruning
- Minmax
- Graham's scan
- Gift wrapping algorithm
- RSA
- AKS primality test
- Miller–Rabin primality test
- Edmonds–Karp algorithm
- Floyd–Warshall algorithm
- Mersenne twister (pseudo-random generator)
- Euclidean algorithm (to compute the greatest common divisor)
- CYK algorithm
- Levenshtein edit distance
- Kosaraju's algorithm

A more exhaustive list of interesting algorithms can be found here:

Expand Down
25 changes: 23 additions & 2 deletions ands/algorithms/dac/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
# Divide and conquer algorithms
# [Divide and conquer algorithms](https://en.wikipedia.org/wiki/Divide_and_conquer_algorithm)

- [https://en.wikipedia.org/wiki/Divide\_and\_conquer\_algorithms](https://en.wikipedia.org/wiki/Divide_and_conquer_algorithms)
A divide and conquer algorithm works by _recursively_ breaking down a problem into
two or more _sub-problems_ of the same or related type, until these become simple
enough to be solved directly.

The solutions to the sub-problems are then combined to give a solution to the
original problem.

The correctness of a divide and conquer algorithm is usually proved by
_mathematical induction_, and its computational cost is often determined by
solving _recurrence relations_.

## Important concepts

- [Recursion](https://en.wikipedia.org/wiki/Recursion_(computer_science))
- Sub-problems
- [Mathematical induction](https://en.wikipedia.org/wiki/Mathematical_induction)
- [Recurrence relations](https://en.wikipedia.org/wiki/Recurrence_relation)
- [Master theorem](https://en.wikipedia.org/wiki/Master_theorem)

### Resources

- [https://brilliant.org/wiki/master-theorem/](https://brilliant.org/wiki/master-theorem/)
9 changes: 2 additions & 7 deletions ands/algorithms/dp/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Dynamic Programming
# [Dynamic Programming](https://en.wikipedia.org/wiki/Dynamic_programming)

## TODO

Expand All @@ -9,9 +9,4 @@
- Counting boolean parenthesization
- Two-CNF-SAT
- Longest bi-tonic subsequence
- Min cost path

## Resources

- [Dynamic Programming](https://en.wikipedia.org/wiki/Dynamic_programming), Wikipedia's article
- [Introduction to Algorithms](https://mitpress.mit.edu/books/introduction-algorithms), 3rd edition, by CLRS
- Min-cost path
14 changes: 3 additions & 11 deletions ands/algorithms/greedy/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
# Greedy Algorithms
# [Greedy Algorithms](https://en.wikipedia.org/wiki/Greedy_algorithm)

Note that algorithms that you might find under [graphs](../graphs), such as [Kruskal](../graphs/kruskal.py)'s and [Prim](../graphs/prim.py)'s or the [Reverse-delete algorithm](Reverse-delete algorithm) algorithms to find minimum-spanning are greedy algorithms. Dijkstra's shortest path algorithm is also a greedy algorithm.

## TODO

## References

- [https://en.wikipedia.org/wiki/Greedy_algorithm](https://en.wikipedia.org/wiki/Greedy_algorithm)

- [Introduction to Algorithms](https://mitpress.mit.edu/books/introduction-algorithms) (3rd edition) by CLRS
- [Reverse-delete algorithm](https://en.wikipedia.org/wiki/Reverse-delete_algorithm) to find a minimum spanning tree.

## TODO

- Greedy graph coloring (does not produce an optimal solution!)

- Change making, which does not produce always an optimal solution. I have already implemented a change making algorithm, which produces an optimal solution, using dynamic programming.

- [Reverse-delete algorithm](https://en.wikipedia.org/wiki/Reverse-delete_algorithm) to find a minimum spanning tree.

2 changes: 1 addition & 1 deletion ands/algorithms/matching/gale_shapley.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def _validate_inputs(men_preferences: list, women_preferences: list, n: int):
raise ValueError("Preferences must be in range [0, n - 1].")


def _build_inverses(women_preferences: list) -> tuple:
def _build_inverses(women_preferences: list) -> list:
"""Builds the inverse matrix of the preferences matrix for women, according
to the algorithm described in the doc-strings above of this module.
Expand Down
14 changes: 1 addition & 13 deletions ands/algorithms/numerical/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1 @@
# Numerical Algorithms

## TODO

- Bisection method
- Fixed-point iteration
- Secant method
- Neville's algorithm (for polynomial interpolation)

- Guassian Elimination
- LU Decomposition (or Factorization)
- Guassian Elimination with Pivoting
- Cholesky Decomposition (for symmetric positive definite matrices)
# Numerical Algorithms
4 changes: 1 addition & 3 deletions ands/algorithms/parsing/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# Parsing

Read the [this article](https://en.wikipedia.org/wiki/Parsing) if you want to know more about parsing.
# [Parsing](https://en.wikipedia.org/wiki/Parsing)
6 changes: 2 additions & 4 deletions ands/algorithms/recursion/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# Recursion
# [Recursion](https://en.wikipedia.org/wiki/Recursion_(computer_science))


Algorithms which are, in my opinion, good and simple examples to show how recursion works.

There are other recursive algorithms in this project that would also be good examples to show how recursion works (for example [`quick_sort`](../sorting/quick_sort.py)), but I thought they would be better examples of other concepts.


## Possibly useful resources

- [https://en.wikipedia.org/wiki/Recursion_(computer_science)](https://en.wikipedia.org/wiki/Recursion_(computer_science))
## Resources

- [https://www.khanacademy.org/computing/computer-science/algorithms/recursive-algorithms/a/recursion](https://www.khanacademy.org/computing/computer-science/algorithms/recursive-algorithms/a/recursion)
10 changes: 1 addition & 9 deletions ands/algorithms/sorting/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sorting Algorithms
# [Sorting Algorithms](https://en.wikipedia.org/wiki/Sorting_algorithm)

Under this folder you can find some of the most famous sorting algorithms, such as

Expand All @@ -10,12 +10,6 @@ All algorithms in this folder are in-place except from merge sort.

The time complexities of the algorithms can be found in the doc-strings of the function. Unless otherwise specified, time complexities are for the worst case.

Other descriptions might be provided, but this is not sure (for now).

In general, I try to specify the type of each argument,
but I might also have forgotten to do it in some places.


## TODO

- Tim sort
Expand All @@ -31,8 +25,6 @@ but I might also have forgotten to do it in some places.

## Resources

- [Sorting Algorithm](https://en.wikipedia.org/wiki/Sorting_algorithm)

- [Sorting and Searching](http://interactivepython.org/runestone/static/pythonds/index.html#sorting-and-searching), section by of an online book at [http://interactivepython.org](http://interactivepython.org)

- Introduction to Algorithm (3rd ed.), book by CRLS.

0 comments on commit 29688f8

Please sign in to comment.