How does free() know the size of memory to be deallocated?

Consider the following prototype of free() function which is used to free memory allocated using malloc() or calloc() or realloc(). filter_none edit close play_arrow link… Read More »

Spaghetti Stack

Spaghetti stack A spaghetti stack is an N-ary tree data structure in which child nodes have pointers to the parent nodes (but not vice-versa) Spaghetti… Read More »

Find the minimum distance between two numbers

Given an unsorted array arr[] and two numbers x and y, find the minimum distance between x and y in arr[]. The array might also… Read More »

A Time Complexity Question

What is the time complexity of following function fun()? Assume that log(x) returns log value in base 2. filter_none edit close play_arrow link brightness_4 code… Read More »

What does ‘Space Complexity’ mean?

Space Complexity: The term Space Complexity is misused for Auxiliary Space at many places. Following are the correct definitions of Auxiliary Space and Space Complexity.… Read More »

Python Program for Longest Common Subsequence

LCS Problem Statement: Given two sequences, find the length of longest subsequence present in both of them. A subsequence is a sequence that appears in… Read More »

Java Program for Longest Common Subsequence

LCS Problem Statement: Given two sequences, find the length of longest subsequence present in both of them. A subsequence is a sequence that appears in… Read More »

C++ Program for Longest Common Subsequence

LCS Problem Statement: Given two sequences, find the length of longest subsequence present in both of them. A subsequence is a sequence that appears in… Read More »

Longest Common Subsequence | DP-4

We have discussed Overlapping Subproblems and Optimal Substructure properties in Set 1 and Set 2 respectively. We also discussed one example problem in Set 3.… Read More »

Find whether an array is subset of another array | Added Method 3

Given two arrays: arr1[0..m-1] and arr2[0..n-1]. Find whether arr2[] is a subset of arr1[] or not. Both the arrays are not in sorted order. It… Read More »

A Boolean Array Puzzle

Input: A array arr[] of two elements having value 0 and 1 Output: Make both elements 0. Specifications: Following are the specifications to follow. 1)… Read More »

Python 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 »

Java 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 »

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 »

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 »