Skip to content

Collection of everyday algorithms - hashing, sorting, graphs, text, scientific algorithms, etc.

License

Notifications You must be signed in to change notification settings

timasjov/famous-algorithms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Collection of simple everyday algorithms

A set of everyday algorithms. Majority of algorithms are implemented in Python, however, some of them are also in Groovy or Java. Majority of implementations in Python (especially scientific algorithms) require several dependencies: numpy, matplotlib, scipy.

Sorting

  • Quicksort, typical divide and conquer implementation. On average runs in O(n log(n)) time complexity, where n is problem size.
  • Radix sort, least significant digit implementation using bucket method. On average runs in O(nk) time complexity, where n is problem size and k is maximum number of digits.

Hashing

  • Universal hashing - implementation of one of the hash functions from universal familiy of hash functions.
  • Bloom filter - implementation of space-efficient probabilistic data structure that is used to test whether an element is a member of a set.

Sample set of keys is also added.

Maximize-minimize expression

Algorithm to maximize and minimize the arithmetic expressions by adding missing * and + signs. I.e., given a list of numbers, e.g. 2 1 3 4, calculate the maximizing placement of operations. E.g. minimum is (2×1)+(3+4)=9, and maximum is (2+1)×3×4=36.

Graph traversals

Sample graph is also added.

Text algorithms

  • Edit distance - implementation of Damerau–Levenshtein distance - distance between two strings, i.e., finite sequence of symbols, given by counting the minimum number of operations needed to transform one string into the other, where an operation is defined as an insertion, deletion, or substitution of a single character, or a transposition of two adjacent characters.

Clustering

  • DBSCAN - pure and simple implementation from pseudocode.
  • OPTICS - implementation produces hierarchical structure of the clusters by creating dendrogram and examining steep down and steep up areas.

Scientific algorithms

  • LU-factorisation - function that performs LU-factorisation of a given matrix A = LU.
  • Gaussian elimination - implementation of partial pivoting in the Gauss elimination method.
  • Curve fitting - simple 2 degree polynomial fit.
  • Gradient descent - implementation of Gradient Descent algorithm with example function and initial guess.
  • Jacobi method - function that solves the system of linear equations using Jacobi method. The function takes a sparse matrix and a right-hand side vector.
  • 1D Laplacian matrix - function that generates 1D Laplace matrix using Dirichlet boundary conditions.
  • 2D Laplacian matrix - function that generates 2D Laplace matrix using Dirichlet boundary conditions.
  • Conjugate gradient method - Conjugate Gradient method with preconditioning for solving sparse linear systems. Is location under other project here.

About

Collection of everyday algorithms - hashing, sorting, graphs, text, scientific algorithms, etc.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published