×
Home Discussions Write at Opengenus IQ
×
  • DSA Cheatsheet
  • HOME
  • Track your progress
  • Deep Learning (FREE)
  • Join our Internship 🎓
  • RANDOM
  • One Liner

Algorithms

Algorithms have proven to be the most important domain over the last century which has reformed the way we do tasks. It is actively used to design industry systems and forms the building blocks of companies like Google. We cover all types of algorithms in depth

Algorithms

Aho Corasick Algorithm

Aho Corasick algorithm is a string algorithm to find or search occurrences of k number of Patterns: P1 ,P2 .... Pk in a string text T. It is a modification over the KMP algorithm

Aman Agarwal Aman Agarwal
Algorithms

Minimum operations to make GCD of array a multiple of k

We are given an array and k, we need to find the minimum operations needed to make GCD of the array equal or multiple of k. Here an operation means either increment or decrement an array element by 1.

Akash Agrawal Akash Agrawal
similarity measurement

Damerau Levenshtein distance

Damerau Levenshtein distance is a variant of Levenshtein distance which is a type of Edit distance. Damerau stated that the four operations in Damerau Levenshtein distance correspond to more than 80% of all human misspellings. It adds an extra operation named transposition to its set of operations

OpenGenus Tech Review Team OpenGenus Tech Review Team
similarity measurement

Levenshtein distance

evenshtein distance is a type of Edit distance which is a large class of distance metric of measuring the dissimilarity between two strings by computing a minimum number of operations (from a set of operations) used to convert one string to another string. It is a way of pairwise string alignment.

OpenGenus Tech Review Team OpenGenus Tech Review Team
similarity measurement

Chebyshev distance

Chebyshev distance is a distance metric which is the maximum absolute distance in one dimension of two N dimensional points. It has real world applications in Chess, Warehouse logistics and many other fields. It is known as Tchebychev distance, maximum metric, chessboard distance and L∞ metric.

OpenGenus Tech Review Team OpenGenus Tech Review Team
similarity measurement

Euclidean distance (L2 norm)

Euclidean distance is the shortest distance between two points in an N dimensional space also known as Euclidean space. It is used as a common metric to measure the similarity between two data points and used in various fields such as geometry, data mining, deep learning and others.

OpenGenus Tech Review Team OpenGenus Tech Review Team
similarity measurement

Manhattan distance [Explained]

Manhattan distance (L1 norm) is a distance metric between two points in a N dimensional vector space. It is the sum of the lengths of the projections of the line segment between the points onto the coordinate axes. It was introduced by Hermann Minkowski. It is used in regression analysis

OpenGenus Tech Review Team OpenGenus Tech Review Team
Algorithms

Manacher's Algorithm

Manacher's Algorithm is an efficient algorithm to find the longest palindromic substring in a given string in linear time and linear space complexity. It uses key ideas from dynamic programming to solve the problem efficiently.

Piyush Mittal Piyush Mittal
Algorithms

Boyer Moore String Search Algorithm

Boyer Moore string search algorithm is an efficient string searching algorithm which was developed by Robert S. Boyer and J Strother Moore in 1977. The time complexity is linear in terms of length of data to be searched and preprocessing complexity is linear as well

Piyush Mittal Piyush Mittal
Algorithms

KMP (Knuth-Morris-Pratt) Algorithm

Given a string S of length n and a pattern P of length m , you have to find all occurences of pattern P in string S provided n > m. Knuth Morris Pratt algorithm is an efficient pattern searching algorithm. Time and space complexity of KMP algorithm is O(m + n) linear.

Piyush Mittal Piyush Mittal
Algorithms

Rabin-Karp Pattern Searching Algorithm

Rabin-Karp Algorithm is an efficient string pattern searching algorithm that utilizes the technique of hashing to search for patterns in a string in linear time by using a clever way of calculating hashes. This algorithm has been developed by Richard M. Karp and Michael O. Rabin in 1987.

Aman Agarwal Aman Agarwal
Genetic Algorithms

Basics of Genetic Algorithms

A genetic algorithm is a search heuristic (related to making guesses) algorithm that is inspired by Charles Darwin’s theory of natural evolution. We have explained the basic concepts of genetic algorithms including initial population, fitness function, selection, crossover and mutation.

OpenGenus Tech Review Team OpenGenus Tech Review Team
bitwise operation

Algorithm to detect whether two numbers have opposite signs using bitwise operators

We present a bitwise algorithm to detect whether two numbers have opposite signs. This is important as using comparision based operations is slow and nearly all hardware support optimizations for bitwise operations

Ashish singh Ashish singh
Algorithms

Maximize sum of consecutive differences in a circular array

Given an array A with values a1, a2, a3, a4, an Now, arrange all elements of array A such that sum of absolute differences of consecutive elements is maximum, i.e consider after an arrangement the array is b1, b2, b3, b4,..., bn then maximize |b1-b2| + |b2-b3| + |b3-b4| + .. + |bn-1-bn| + |bn-b1|

Piyush Mittal Piyush Mittal
bitwise operation

Bitwise Algorithm to Find the Number Occurring with Odd Frequency

We have explored the bitwise algorithm to find the only number occuring odd number of times in a given set of numbers. We have used the XOR operator to solve this problem in O(N) time complexity in contrast to the native algorithm which takes O(N^2) time complexity. The space complexity is constant.

Piyush Mishra
bitwise operation

Maximise XOR of a given integer with a number from the given range

Given q queries each of specifies three integers x, l, r. We have to find an integer from given range [l, r] inclusive, such that it gives maximum XOR with x. All values are assumed to be positive. We will show two ways to solve this interesting problem.

Aman Agarwal Aman Agarwal
multiplication

Toom Cook method for multiplication

Multiplication of two n-digits integers has time complexity at worst O(n^2).Toom-Cook algorithm is an algorithm for multiplying two n digit numbers in Θ(c(k)n^e) time complexity. The idea is based on divide-and-conquer technique

Kyatham Srikanth Kyatham Srikanth
matrix multiplication

Cannon’s algorithm for distributed matrix multiplication

Cannon's algorithm is a distributed algorithm for matrix multiplication for two-dimensional meshes. It is especially suitable for computers laid out in an N × N mesh. The main advantage of the algorithm is that its storage requirements remain constant and are independent of the number of processors.

Kyatham Srikanth Kyatham Srikanth
matrix multiplication

Freivalds’ algorithm for verifying Matrix Multiplication

Freivalds' algorithm is a probabilistic randomized algorithm used to verify matrix multiplication. Given three n x n matrices, Freivalds' algorithm determines in O(kn^2) whether the matrices are equal for a chosen k value with a probability of failure less than 2^-k.

Kyatham Srikanth Kyatham Srikanth
matrix multiplication

Russian peasant multiplication algorithm

Russian peasant multiplication is an interesting way to multiply numbers that uses a process of halving and doubling without using multiplication operator. The idea is to double the first number and halve the second number repeatedly till the second number doesn’t become 1

Kyatham Srikanth Kyatham Srikanth
matrix multiplication

Strassen’s Matrix Multiplication algorithm

Strassen’s Matrix Multiplication algorithm is the first algorithm to prove that matrix multiplication can be done at a time faster than O(N^3). It utilizes the strategy of divide and conquer to reduce the number of recursive multiplication calls from 8 to 7 and hence, the improvement.

Kyatham Srikanth Kyatham Srikanth
Algorithms

Graph Coloring Greedy Algorithm [O(V^2 + E) time complexity]

In this article, we have explored the greedy algorithm for graph colouring. graph coloring is a special case of graph labeling ; it is an assignment of labels traditionally called "colors" to elements of a graph subject to certain constraints.

Pankaj Sharma Pankaj Sharma
Algorithms

Wigderson Graph Colouring Algorithm in O(N+M) time

Wigderson Algorithm is a graph colouring algorithm to color any n-vertex 3-colorable graph with O(√n) colors, and more generally to color any k-colorable graph. In this article, we have explored this wonderful graph colouring article in depth.

Pankaj Sharma Pankaj Sharma
Algorithms

Welsh Powell Algorithm for graph coloring in O(N^2) time

Welsh Powell algorithm is used to implement graph labeling; it is an assignment of labels traditionally called "colors" to elements of a graph subject to certain constraints

Pankaj Sharma Pankaj Sharma
Algorithms

The Coin Change Problem

Given a set of coins S with values { S1, S2, ..., Sm }, find the number of ways of making the change to a certain value N. There is an infinite quantity of coins and the order of the coins doesn't matter. This real life problem can be solved by Dynamic Programming in

Akash A. Gajjar Akash A. Gajjar
OpenGenus IQ © 2025 All rights reserved â„¢
Contact - Email: team@opengenus.org
Primary Address: JR Shinjuku Miraina Tower, Tokyo, Shinjuku 160-0022, JP
Office #2: Commercial Complex D4, Delhi, Delhi 110017, IN
Top Posts LinkedIn Twitter
Android App
Apply for Internship