Skip to content

Category Archives: Algorithms

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 that we wish to… 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… 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
Given a string of length n, print all permutations of the given string. Repetition of characters is allowed. Print these permutations in lexicographically sorted order … Read More
Given the dimension of a sequence of matrices in an array arr[], where the dimension of the ith matrix is (arr[i-1] * arr[i]), the task… Read More
Given an integer array of coins[ ] of size N representing different types of currency and an integer sum, The task is to find the number of… Read More
Given an array arr[] where each element represents the max number of steps that can be made forward from that index. The task is to… Read More
Difficulty Level: Rookie Given a stream of numbers, print the average (or mean) of the stream at every point. For example, let us consider the… Read More
Given an array of integers which is initially increasing and then decreasing, find the maximum value in the array. Examples :  Input: arr[] = {8, 10,… Read More
Given two integers k and n, write a function that prints all the sequences of length k composed of numbers 1,2..n. You need to print… Read More

Start Your Coding Journey Now!