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

The diameter of a tree (sometimes called the width) is the number of nodes on the longest path between two end nodes. In this post,… Read More »

- Check if given Preorder, Inorder and Postorder traversals are of same tree | Set 2
- Kth smallest element in a subarray
- Introduction to Data Structures | 10 most commonly used Data Structures
- Iterative Postorder traversal | Set 3
- Total number of possible Binary Search Trees using Catalan Number
- Convert a given Binary Tree to Circular Doubly Linked List | Set 2
- Adobe Interview Experience ( 3 Years Exp )
- Find the node with maximum value in a Binary Search Tree using recursion
- Burn the binary tree starting from the target node
- K-th ancestor of a node in Binary Tree | Set 3
- Calculate height of Binary Tree using Inorder and Level Order Traversal
- Pair with a given sum in BST | Set 2
- Check which player visits more number of Nodes
- Find the node with minimum value in a Binary Search Tree using recursion
- Construct BST from its given level order traversal | Set-2
- Minimum steps to color the tree with given colors
- Number of pairs with a given sum in a Binary Search Tree
- Print Bottom-Right View of a Binary Tree
- Sum of the distances from every node to all other nodes is maximum
- Queries for number of distinct elements in a subarray | Set 2
- Print Binary Search Tree in Min Max Fashion
- Find the largest Complete Subtree in a given Binary Tree
- Count all k-sum paths in a Binary Tree
- Reverse tree path using Queue
- Cartesian tree from inorder traversal | Segment Tree
- Insertion in n-ary tree in given order and Level order traversal
- Find maximum and minimum element in binary tree without using recursion or stack or queue
- Generic Trees(N-array Trees)
- Queries to update a given index and find gcd in range
- Longest subsequence with first and last element greater than all other elements

The diameter of a tree (sometimes called the width) is the number of nodes on the longest path between two end nodes. In this post,… Read More »

Given a binary tree. Find if a given vertical level of the binary tree is sorted or not. (For the case when two nodes are… Read More »

There is a tree with N nodes and node 1 is the root node. Each node of the tree can contain fruit or not. Initially,… Read More »

Given a Binary Search Tree(BST), convert it to a Binary Tree such that every key of the original BST is changed to key plus sum… Read More »

Given a node x, find the number of children of x(if it exists) in the given n-ary tree. Example : Input : x = 50… Read More »

Given a tree, and the cost of a subtree is defined as |S|*AND(S) where |S| is the size of the subtree and AND(S) is bitwise… Read More »

Given a tree and weights of nodes. Weights are non-negative integers. Task is to find maximum size of a subtree of a given tree such… Read More »

Given an N-ary tree, find the number of siblings of given node x. Assume that x exists in the given n-ary tree. Example : Input… Read More »

Given N numbers and Q queries, each query consists of L and R. Task is to write a program which prints the count of numbers… Read More »

Given a binary tree, task is to find subtree with maximum sum in tree. Examples: Input : 1 / \ 2 3 / \ /… Read More »

Given a rectangular matrix M[0…n-1][0…m-1], and queries are asked to find the sum / minimum / maximum on some sub-rectangles M[a…b][e…f], as well as queries… Read More »

An ordered tree is an oriented tree in which the children of a node are somehow ordered. It is a rooted tree in which an… Read More »

Euler tour tree (ETT) is a method for representing a rooted tree as a number sequence. When traversing the tree using Depth for search(DFS), insert… Read More »

Given N pieces of chessboard all being ‘white’ and a number of queries Q. There are two types of queries : Update : Given indices… Read More »

Given a binary tree, print the level order traversal in such a way that first two levels are printed from left to right, next two… Read More »