Gblog First Step to DSA – Scholarship Test For 9 to 12 Class Students
“Start Early even if your destination is quite far away” – this success mantra always works for everyone whether it be a student, a sportsperson,… Read More
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
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 can… Read More
As we discussed in Set 1, following are the two main properties of a problem that suggest that the given problem can be solved… Read More
Dynamic Programming is an algorithmic paradigm that solves a given complex problem by breaking it into subproblems and stores the results of subproblems to… Read More
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
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
An ordinary Doubly Linked List requires space for two address fields to store the addresses of previous and next nodes. It is represented as follows… Read More
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
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
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
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
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
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… Read More
Interpolation search works better than Binary Search for a Sorted and Uniformly Distributed array.  Binary Search goes to the middle element to check irrespective of… Read More
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