Posts that are related to Recursion.

## Construct XOR tree by Given leaf nodes of Perfect Binary Tree

Given the leaf nodes of a perfect binary tree, the task is to construct the XOR tree and print the root node of this tree.… Read More »

## Construct Binary Tree from Ancestor Matrix | Top Down Approach

Given an ancestor matrix mat[n][n] where the ancestor matrix is defined as below. mat[i][j] = 1 if i is ancestor of j mat[i][j] = 0,… Read More »

## Count of non-empty sequences of a String

Given a string s, the task is to find the number of possible non-empty sequences of letters that can be made. Examples: Input: “AAB” Output:… Read More »

## Print all possible paths from the first row to the last row in a 2D array

Given a 2D array of characters with M rows and N columns. The task is to print all the possible paths from top (first row)… Read More »

## Print path between any two nodes in a Binary Tree | Set 2

Given a Binary Tree of distinct nodes and a pair of nodes. The task is to find and print the path between the two given… Read More »

## Count ways to reach the Nth stair using any step from the given array

Given N stairs and a person standing at the bottom wants to reach the top. He could climb any number of steps from the given… Read More »

## Check whether the given node is in the path between the nodes U and V

Given three vertices U, V and R of a binary tree, the task is to check whether R lies in the path between U and… Read More »

## Count of nodes that are greater than Ancestors

Given the root of a tree, the task is to find the count of nodes which are greater than all of its ancestors. Examples: Input:… Read More »

## Kth ancestor of a node in an N-ary tree using Binary Lifting Technique

Given a vertex V of an N-ary tree and an integer K, the task is to print the Kth ancestor of the given vertex in… Read More »

## Queries for elements greater than K in the given index range using Segment Tree

Given an array arr[] of N elements and a number of queries where each query will contain three integers L, R and K. For each… Read More »

## Cyclic Iterator for K variable length vectors

Given K vectors, the task is to design a cyclic iterator that prints the elements of these vectors in a cyclic manner. For example: v1… Read More »

## Minimum cost to partition the given binary string

Given a binary string str and an integer K, the task is to find the minimum cost required to partition the string into exactly K… Read More »

## Print completed tasks at end according to Dependencies

Given N dependencies of the form X Y, where X & Y represents two different tasks. The dependency X Y denotes dependency of the form… Read More »

## Find the parent of a node in the given binary tree

Given a tree and a node, the task is to find the parent of the given node in the tree. Print -1 if the given… Read More »

## Java Program to Calculate Power of a Number

Given a number N and a power P, the task is to find the exponent of this number raised to the given power, i.e. NP.… Read More »