# Category Archives: Recursion (adsbygoogle = window.adsbygoogle || []).push({});

Posts that are related to Recursion.

## Distinct strings such that they contains given strings as sub-sequences

Given two strings str1 and str2 of lengths M and N respectively. The task is to find all the distinct string of length M +… Read More »

## Strings from an array which are not prefix of any other string

Given an array arr[] of strings, the task is to print the strings from the array which are not prefix of any other string from… Read More »

## Generate all possible strings such that char at index i is either str1[i] or str2[i]

Given two strings str1 and str2 each of length N, the task is to generate and print all possible strings of length N such that… Read More »

## Decimal to Binary using recursion and without using power operator

Given an integer N, the task is convert and print the binary equaiva;ent of N. Examples: Input: N = 13 Output: 1101 Input: N =… Read More »

## Cost Based Tower of Hanoi

The standard Tower of Hanoi problem is explained here . In the standard problem, all the disc transactions are considered identical. Given a 3×3 matrix… Read More »

## Cartesian tree from inorder traversal | Segment Tree

Given an in-order traversal of a cartesian tree, the task is to build the entire tree from it. Examples: Input: arr[] = {1, 5, 3}… Read More »

## Add one to a number represented as linked list | Set 2

Given a singly linked list which represents a number where each node contains only one digit [0 – 9]. The task is to add 1… Read More »

## Flip minimum signs of array elements to get minimum sum of positive elements possible

Given an array of positive elements, you have to flip the sign of some of its elements such that the resultant sum of the elements… Read More »

## Types of Recursions

What is Recursion? The process in which a function calls itself directly or indirectly is called recursion and the corresponding function is called as recursive… Read More »

## Total number of possible Binary Search Trees using Catalan Number

Given an integer N, the task is to count the number of possible Binary Search Trees with N keys. Examples: Input: N = 2 Output:… Read More »

## Find the node with maximum value in a Binary Search Tree using recursion

Given a Binary Search Tree, the task is to find the node with maximum value. Examples: Input: Output: 22 Recommended: Please try your approach on… Read More »

## Maximum sum of non-overlapping subarrays of length atmost K

Given an integer array ‘arr’ of length N and an integer ‘k’, select some non-overlapping subarrays such that each sub-array if of length at most… Read More »

## Merge two BSTs with constant extra space

Given two Binary Search Trees(BST), print the elements of both BSTs in sorted form. Note: Both the BSTs will not have any common element. Examples:… Read More »

## Number of ways to choose elements from the array such that their average is K

Given an array arr[] of N integers and an integer K. The task is to find the number of ways to select one or more… Read More »

## Subset with sum closest to zero

Given an array ‘arr’ consisting of integers, the task is to find the non-empty subset such that its sum is closest to zero i.e. absolute… Read More »