## Depth First Search/Traversal in Binary Tree

Objective: – Given a Binary Search Tree, Do the Depth First Search/Traversal . Appraoch: Approach is quite simple, use Stack. First add the add root to the Stack. Pop out an element from Stack...

Objective: – Given a Binary Search Tree, Do the Depth First Search/Traversal . Appraoch: Approach is quite simple, use Stack. First add the add root to the Stack. Pop out an element from Stack...

Objective: – Given a Binary Search Tree, Find predecessor and Successor of a given node. What is Predecessor and Successor : When you do the inorder traversal of a binary tree, the neighbors of...

Objective: – Given Binary Tree, Print All The Nodes Which are X distance from the Leaf Nodes Example : Approach:

Objective: – Given Binary Tree, Print all the nodes which are X distance from the root Example : Appraoch:

Objective: – Given nodes in a binary tree, find the distance between them. Example : Approach:

Objective: – Find The Distance From Root To Given Node of a binary tree. What does Distance means : It means number of edges between two nodes. Approach:

Objective: – Given a inorder and postorder traversal, write an algorithm to construct a binary tree from that. This problem was asked in the Microsoft coding competition. Input: Inorder and postorder traversals Similar Problems:...

Objective: – Given a binary tree, print it in vertical order sum What is Vertical Order Sum as you can see in the example above, [4],[2], [12],[3],[7] are the vertical order sum of the...

Objective: – Given a binary tree, print it in vertical order path. What is Vertical Order as you can see in the example above, [4],[2], [1,5,6],[3],[7] are the verical order of the given binary...

Objective: – Find the Lowest Common Ancestor of two given nodes in a Binary Tree What is Lowest Common Ancestor In a given binary tree, The lowest common ancestor of two nodes n1 and...

Objective: – Find the Lowest Common Ancestor of two given nodes in a Binary Search Tree What is Lowest Common Ancestor In a given binary tree, The lowest common ancestor of two nodes n1...

Objective: – Given a inorder and preorder traversal, construct a binary tree from that. Input: Inorder and preorder traversals Similar Problem: Construct a binary tree from given Inorder and Postorder Traversal Approach: int []...

Objective: – Find the maximum sum leaf to root path in a Binary Tree. Means in all the paths from root to leaves, find the path which has the maximum sum. Input: A binary...

Objective: – Reverse Alternate levels of a given binary tree Input: A binary tree Example: Appraoch:

Objective: You have been given a sorted singly List, you need to convert it into balanced binary search tree. Why balanced binary tree is important: You can also create first node as root and...

%d bloggers like this: