# Category Archives: Recursion

Posts that are related to Recursion.

## Maximal Independent Set in an Undirected Graph

Given an undirected graph defined by the number of vertex V and the edges E[ ], the task is to find Maximal Independent Vertex Set… Read More »

## Replace all occurrences of character X with character Y in given string

Given a string str and two characters X and Y, the task is to write a recursive function to replace all occurrences of character X… Read More »

## Maximum value of Bitwise AND from root to leaf in a Binary tree

Given a Binary Tree, the task is to find the maximum value of Bitwise AND from any path from the root node to the leaf… Read More »

## Difference between sum of even and odd valued nodes in a Binary Tree

Given a binary tree, the task is to find the absolute difference between the even valued and the odd valued nodes in a binary tree.… Read More »

## Print the nodes that are just above the leaf node

Given a binary tree consisting of N nodes, the task is to print the nodes that are just above the leaf node. Examples: Input: N… Read More »

## Calculate weight of parenthesis based on the given conditions

Given a valid parenthesis string S, the task is to find the weight of parenthesis based on the following conditions: Weight of “( )” is… Read More »

## Longest Increasing Subsequence having sum value atmost K

Given an integer array arr[] of size N and an integer K. The task is to find length of longest subsequence whose sum is less… Read More »

## Maximise number of cuts in a rod if it can be cut only in given 3 sizes

Given a rod of length N meters, and the rod can be cut in only 3 sizes A, B and C. The task is to… Read More »

## Different Types of Recursion in Golang

Recursion is a concept where a function calls itself by direct or indirect means. Each call to the recursive function is a smaller version so… Read More »

## Print the nodes of Binary Tree having a grandchild

Given a Binary Tree, the task is to print the nodes that have grandchildren. Examples: Input: Output: 20 8 Explanation: 20 and 8 are the… Read More »

## Check if the Binary Tree contains a balanced BST of size K

Given a Binary Tree and a positive integer K. The task is to check whether the Balanced BST of size K exist in a given… Read More »

## Check if a string can be split into substrings starting with N followed by N characters

Given a string str, the task is to check if it can be split into substrings such that each substring starts with a numeric value… Read More »

## Maximum cost path in an Undirected Graph such that no edge is visited twice in a row

Given an undirected graph having N vertices and M edges and each vertex is associated with a cost and a source vertex S is given.… Read More »

## Print the longest path from root to leaf in a Binary tree

Given a binary tree, the task is to print the longest path from the root node to the leaf node. If there are multiple answers… Read More »

## Count of numbers upto N digits formed using digits 0 to K-1 without any adjacent 0s

Given two integers N and K, the task is to count the numbers up to N digits such that no two zeros are adjacents and… Read More »