# Category Archives: Tree

## Check whether every node of binary tree has a value K on itself or its any immediate neighbours

Given a binary tree and a value K, the task is to check if every node of the binary tree has either value of the… Read More »

## Count of root to leaf paths in a Binary Tree that form an AP

Given a Binary Tree, the task is to count all paths from root to leaf which forms an Arithmetic Progression. Examples: Input: Output: 2 Explanation:… Read More »

## Lexicographical smallest number after at most K consecutive swaps

Given a number in form of string str and an integer K, the task is to find the smallest integer that can be formed after… Read More »

## Specific Level Order Traversal of Binary Tree

Given a Binary Tree, the task is to perform Specific Level Order Traversal of the tree such that at each level print 1st element then… Read More »

## Median of sliding window in an array | Set 2

Prerequisites: Policy based data structure, Sliding window technique. Given an array of integer arr[] and an integer K, the task is to find the median… 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 »

## Find the node at the centre of an N-ary tree

Prerequisites: Diameter of a N-ary tree Path between two nodes in a graph Given a N-ary tree with N nodes numbered from 0 to N-1… 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 »

## Insertion in a B+ tree

Prerequisite: Introduction of B+ trees In this article, we will discuss that how to insert a node in B+ Tree. During insertion following properties of… 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 »

## 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 two nodes are on same path in a tree | Set 2

Given two nodes of a binary tree v1 and v2, the task is to check if two nodes are on the same path in a… 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 »

## Maximum number of bridges in a path of a given graph

Given an undirected graph, the task is to count the maximum number of Bridges between any two vertices of the given graph. Examples: Input: Graph… Read More »