## C/C++ Program for Longest Increasing Subsequence

The Longest Increasing Subsequence (LIS) problem is to find the length of the longest subsequence of a given sequence such that all elements of the… Read More »

## Longest Increasing Subsequence | DP-3

We have already discussed Overlapping Subproblems and Optimal Substructure properties. Now, let us discuss the Longest Increasing Subsequence (LIS) problem as an example problem that… Read More »

## Optimal Substructure Property in Dynamic Programming | DP-2

As we discussed in Set 1, following are the two main properties of a problem that suggest that the given problem can be solved using… Read More »

## Overlapping Subproblems Property in Dynamic Programming | DP-1

Dynamic Programming is an algorithmic paradigm that solves a given complex problem by breaking it into subproblems and stores the results of subproblems to avoid… Read More »

## Time Complexity of building a heap

Consider the following algorithm for building a Heap of an input array A. BUILD-HEAP(A) heapsize := size(A); for i := floor(heapsize/2) downto 1 do HEAPIFY(A,… Read More »

## Sliding Window Maximum (Maximum of all subarrays of size k)

Given an array and an integer K, find the maximum for each and every contiguous subarray of size k. Examples : Input: arr[] = {1,… Read More »

## XOR Linked List – A Memory Efficient Doubly Linked List | Set 1

An ordinary Doubly Linked List requires space for two address fields to store the addresses of previous and next nodes. A memory efficient version of… Read More »

## Given an array arr[], find the maximum j – i such that arr[j] > arr[i]

Given an array arr[], find the maximum j – i such that arr[j] > arr[i]. Examples : Input: {34, 8, 10, 3, 2, 80, 30,… Read More »

## PHP Program for Rabin-Karp Algorithm for Pattern Searching

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 »

## Python Program for Rabin-Karp Algorithm for Pattern Searching

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 »

## Java Program for Rabin-Karp Algorithm for Pattern Searching

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 »

## C Program for Rabin-Karp Algorithm for Pattern Searching

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 »

## Rabin-Karp Algorithm for Pattern Searching

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 »

## Interpolation search vs Binary search

Interpolation search works better than Binary Search for a sorted and uniformly distributed array. On average the interpolation search makes about log(log(n)) comparisons (if the… Read More »

## Detect and Remove Loop in a Linked List

Write a function detectAndRemoveLoop() that checks whether a given Linked List contains loop and if loop is present then removes the loop and returns true.… Read More »