Given a non-empty binary tree, find the maximum path sum.

For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child … Read More

Interview Questions asked in Google, Microsoft, Amazon

Given a non-empty binary tree, find the maximum path sum.

For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child … Read More

by Dhaval Dave

Given a Binary Tree, print the diagonal traversal of the binary tree

Consider lines of slope -1 passing between nodes. Given a Binary Tree, print all diagonal elements in a binary tree belonging to same … Read More

by Dhaval Dave

In a Binary Search Tree (BST), all keys in left subtree of a key must be smaller and all keys in right subtree must be greater. So a Binary Search Tree by definition has distinct … Read More

by Dhaval Dave

Find weather two given trees are isomorphic to each other or not.

Lets understand What is isomorphic strings

AAB and XXY are IsoMorphic to each other, consider A replaces/morphs as X and B as Y, … Read More

by Dhaval Dave

We are given a Binary Tree, Print the Right view of Binary tree,

Right view of binary tree is : List of all nodes which are visible If you look at Binary tree from right … Read More

by Dhaval Dave

If a binary tree is given, how to find Maximum path sum between two leaves of binary tree.

All should be numbers The maximum sum path may or may not go through root. For example, |

by Dhaval Dave

by Dhaval Dave

A Height Balanced Tree is tree where for each node this condition is true.

– The difference between heights of left subtree and right subtree for any node is not more than 1.So we can

… Read More – The difference between heights of left subtree and right subtree for any node is not more than 1.So we can

by Dhaval Dave

Write a function to print spiral order traversal of a tree or Write function for Tree traversal in Spiral ZigZag form

For below tree, function should print 1, 2, 3, 7, 6, 5, 4.

For below tree, function should print 1, 2, 3, 7, 6, 5, 4.

[1]

by Dhaval Dave

We need to find a Least Common Ancestor of Two given nodes in Binary tree.

[1] / \ [2] [3] / \ / \ [4] [5] [9] [10] / / \ [8] [6] [7]

say