Algorithms

This category contains all the posts related to Algorithms. For e.g.: Sorting, Hashing, Searching, Tree Traversals, Graph Theory etc.

Minimum Edit Distance

This blog post is primarily focused on strengthening the concept of Dynamic Programming by using Minimum Edit Distance problem. Although you won't require any knowledge of Dynamic Programming to understand this post. However, if you are also looking for an elaborate explanation of Dynamic Programming, then please visit this post . What is Minimum Edit Distance ? Given two strings P and Q, it is possible to transform P into Q or vice-versa by performing the following operations on one of the strings. For e.g let us assume that we need to transform the string P into the string Q. Then, the fol...
Read More

Solving 0/1 Knapsack problem using Dynamic Programming

Introduction A knapsack is a bag with straps, usually carried by soldiers to help them take their valuables or things which they might need during their journey. The 0/1 knapsack problem is a very famous interview problem. The problem statement is as follows: Given a set of items, each of which is associated with some weight and value. Find the subset of items which can be carried into the knapsack with weight limit W. It is required that the cumulative value of the items in the knapsack is maximum value possible. In simple words, it asks you to pick certain items from the set of items ...
Read More

Solving 0/1 Knapsack problem using Recursion

Introduction A knapsack is a bag with straps, usually carried by soldiers to help them take their valuables or things which they might need during their journey. The 0/1 knapsack problem is a very famous interview problem. The problem statement is as follows: Given a set of items, each of which is associated with some weight and value. Find the subset of items which can be carried in a knapsack of capacity W (where W is the weight). It is required that the cumulative value of the items in the knapsack is maximum value possible. In simple words, it asks you to pick certain items from the...
Read More

Find Interleaving Strings using Dynamic Programming

Introduction This problem is already discussed in the post here. This post attempts to solve the same using the dynamic programming approach. Here is a brief description of the problem. Given three strings A, B and C such that A is "ab", B is "ade" and C is "adabe" find if C is an interleaving of A and B or not. Interleaving means constructing the third string C using the characters of A and B such that the characters in A and B preserve their relative ordering in C. In the above example C is an interleaving of A and B. Approach to Find Interleaving Strings using Dynamic Programming How ...
Read More

Solving Sudoku using Backtracking

Introduction This post is the continuation of the backtracking series. Sudoku can be solved using multiple algorithms based on Neural Networks and Genetic Algorithms by doing exhaustive searches in the solution space. However, here we are focusing on solving Sudoku using backtracking algorithm. For people who are unaware of the Sudoku puzzle, please check out Wikipedia for details. For a brief description read below: A Sudoku puzzle is a 9 * 9 grid. Few cells in the grid contain random numbers between 1 and 9 (both inclusive) A fully solved Sudoku must contain numbers through 1-...
Read More