## LCA for general or n-ary trees (Sparse Matrix DP approach < O(nlogn), O(logn)>)

In previous posts, we have discussed how to calculate the Lowest Common Ancestor (LCA) for a binary tree and a binary search tree (this, this… Read More »

- MakeMyTrip Interview Experience 2019
- Print the nodes of binary tree as they become the leaf node
- Iterative Method To Print Left View of a Binary Tree
- Shannon-Fano Algorithm for Data Compression
- Count the Number of Binary Search Trees present in a Binary Tree
- Print path between any two nodes in a Binary Tree
- Flatten a binary tree into linked list | Set-3
- Zig-Zag traversal of a Binary Tree using Recursion
- Difference between graph and tree
- Shortest root to leaf path sum equal to a given number
- Remove minimum elements from either side such that 2*min becomes more than max | Set 2
- Clockwise Spiral Traversal of Binary Tree
- Reverse zigzag Traversal of a Binary Tree
- Sum of nodes at maximum depth of a Binary Tree | Set 2
- Number of subarrays have bitwise OR >= K
- Check if the given Binary Tree have a Subtree with equal no of 1's and 0's
- Iterative Boundary traversal of Complete Binary tree
- Count all Grandparent-Parent-Child Triplets in a binary tree whose sum is greater than X
- Reverse Level Order traversal in spiral form
- Find the number of distinct pairs of vertices which have a distance of exactly k in a tree
- Building Expression tree from Prefix Expression
- Print All Leaf Nodes of a Binary Tree from left to right | Set-2 ( Iterative Approach )
- Spanning Tree With Maximum Degree (Using Kruskal's Algorithm)
- Sum of all odd nodes in the path connecting two given nodes
- Print all the levels with odd and even number of nodes in it | Set-2
- Range Sum Queries and Update with Square Root
- Check if the given binary tree has a sub-tree with equal no of 1's and 0's | Set 2
- Sum of all the Boundary Nodes of a Binary Tree
- Check if given Preorder, Inorder and Postorder traversals are of same tree | Set 2
- Distribute candies in a Binary Tree

In previous posts, we have discussed how to calculate the Lowest Common Ancestor (LCA) for a binary tree and a binary search tree (this, this… Read More »

Given a Binary tree, find out depth of the deepest odd level leaf node. Take root level as depth 1. Examples: Input : Output :… Read More »

Given preorder of a binary tree, calculate its depth(or height) [starting from depth 0]. The preorder is given as a string with two possible characters.… Read More »

Given a Binary search Tree that contains positive integer values greater then 0. The task is to check whether the BST contains a dead end… Read More »

Given a binary search tree and a target node K. The task is to find the node with minimum absolute difference with given target value… Read More »

Given an array of n integers, each integer is greater than 1. The task is to find the number of Full binary tree from the… Read More »

You are given a binary tree and a given sum. The task is to check if there exist a subtree whose sum of all nodes… Read More »

Given a binary tree and a integer value K, the task is to find all nodes in given binary tree having K leaves in subtree… Read More »

Given a binary tree with a value associated with each node, we need to choose a subset of these nodes such that sum of chosen… Read More »

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

Given a binary tree, print the number of root to leaf paths having equal lengths. Examples: Input : Root of below tree 10 / \… Read More »

A tree is Continuous tree if in each root to leaf path, absolute difference between keys of two adjacent is 1. We are given a… Read More »

Given a binary tree, find if there is a pair in root to a leaf path such that sum of values in pair is equal… Read More »

It was a walk-in for experienced candidates actually. Round 1: Machine Coding Round (60 min) Q1. Infix to Postfix conversion e.g. A+(B-C)*D becomes ABC-D*+ Q2.… Read More »

Given a binary tree and an array, the task is to find if the given array sequence is present as a root to leaf path… Read More »