Skip to content

Category Archives: Algorithms

Given an array of n positive integers. Write a program to find the sum of maximum sum subsequence of the given array such that the… Read More
  Given a rod of length n inches and an array of prices that includes prices of all pieces of size smaller than n. Determine… Read More
  Given a sequence, find the length of the longest palindromic subsequence in it.  As another example, if the given sequence is “BBABCBCAB”, then the… Read More
Hamiltonian Path in an undirected graph is a path that visits each vertex exactly once. A Hamiltonian cycle (or Hamiltonian circuit) is a Hamiltonian Path… Read More
In the previous post, we discussed the Finite Automata-based pattern searching algorithm. The FA (Finite Automata) construction method discussed in the previous post takes O((m^3)*NO_OF_CHARS)… Read More
Given an undirected graph and a number m, determine if the graph can be colored with at most m colors such that no two adjacent… Read More
Given a number x and two positions (from the right side) in the binary representation of x, write a function that swaps n bits at… Read More
Given a text txt[0..n-1] and a pattern pat[0..m-1], write a function search(char pat[], char txt[]) that prints all occurrences of pat[] in txt[]. You may… Read More
The following is a description of the instance of this famous puzzle involving N = 2 eggs and a building with K = 36 floors.Suppose… Read More
Given two Linked Lists, create union and intersection lists that contain union and intersection of the elements present in the given lists. The order of… Read More
Greedy is an algorithmic paradigm that builds up a solution piece by piece, always choosing the next piece that offers the most obvious and immediate… Read More
Given weights and values of N items, put these items in a knapsack of capacity W to get the maximum total value in the knapsack.… Read More
C++ #include <iostream> using namespace std;   int add(int a, int b) {     // for loop will start from 1 and move till the value… Read More
In the previous post, we discussed how Asymptotic analysis overcomes the problems of the naive way of analyzing algorithms. But let’s take an overview of… Read More
The following are the common definitions of Binomial Coefficients.  A binomial coefficient C(n, k) can be defined as the coefficient of x^k in the expansion… Read More

Start Your Coding Journey Now!