Posts that are related to Recursion.

## Divide the array in K segments such that the sum of minimums is maximized

Given an array a of size N and an integer K, the task is to divide the array into K segments such that sum of… Read More »

## Reverse tree path using Queue

Given a tree and a node, the task is to reverse the path till the given Node and print the in-order traversal of the modified… Read More »

## Sort the Queue using Recursion

Given a queue and the task is to sort it using recursion without using any loop. We can only use the following functions of queue:… Read More »

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