# Tag Archives: tree-traversal

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

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

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

## Double Threaded Binary Search Tree

Double Threaded Binary Search Tree: is a binary search tree in which the nodes are not every left NULL pointer points to its inorder predecessor… Read More »

## Level order traversal of Binary Tree using Morris Traversal

Given a binary tree, the task is to traverse the Binary Tree in level order fashion. Examples: Input: 1 / \ 2 3 Output: 1… Read More »

## Minimum cost to colour a Tree with no 3 adjacent vertices having same colour

Given a tree with N nodes value from 0 to (N – 1) and a 2D array arr[][] of size dimensions 3xN, where arr[i][j] denotes… Read More »

## Maximum difference of count of black and white vertices in a path containing vertex V

Given a Tree with N vertices and N – 1 edges where the vertices are numbered from 0 to N – 1, and a vertex… Read More »

## Maximum absolute difference between any two level sum in a Binary Tree

Given a Binary Tree having positive and negative nodes, the task is to find the maximum absolute difference of level sum in it. Examples: Input:… Read More »

## Check if the given permutation is a valid BFS of a given Tree

Given a tree with N nodes numbered from 1 to N and an permutation array of numbers from 1 to N. Check if it is… Read More »

## Count of root to leaf paths whose permutation is palindrome in a Binary Tree

Given a binary tree where node contains characters, the task is to count the number of paths from root vertex to leaf such that at… Read More »

## Sum of all the child nodes with even grandparents in a Binary Tree

Given a Binary Tree, calculate the sum of nodes with even valued Grandparents. Examples: Input: 22 / \ 3 8 / \ / \ 4… Read More »

## Minimum time required to visit all the special nodes of a Tree

Given an undirected tree consisting of N vertices where some of the nodes are special nodes, the task is to visit all the special nodes… Read More »

## Maximum XOR path of a Binary Tree

Given a Binary Tree, the task is to find the maximum of all the XOR value of all the nodes in the path from the… Read More »

## Print the nodes having exactly one child in a Binary tree

Given a binary tree, the task is to print all the nodes having exactly one child. Print “-1” if no such node exists. Examples: Input:… Read More »

## Middle To Up-Down Order traversal of a Binary Tree

Given a binary tree, the task is to traverse this binary tree from the middle to the up-down order. In Middle to up-down order traversal,… Read More »