Deletion from BST (Binary Search Tree)

Given a BST, write an efficient function to delete a given key in it.

Insertion in BST | Recursive & Iterative Solution

A Binary Search Tree (BST) is a rooted binary tree, whose nodes each store a key (and optionally, an associated value) and each have two distinguished sub-trees, commonly denoted left and right. The tree should satisfy the BST property, which states that the key in each node must be greater than all keys stored …

Find maximum sum root to leaf path in a binary tree

Given a binary tree, write an efficient algorithm to find maximum sum root to leaf path i.e. maximum sum path from root node to any leaf node in it.

Truncate binary tree to remove nodes which lie on a path having sum less than K

Given a binary tree, a complete path is defined as a path from root to a leaf. The sum of all nodes on that path is defined as the sum of that path. Given a number K, remove nodes from the tree which lie on a path having sum less than K.

In-place convert convert given Binary Tree to Doubly Linked List

Given a binary tree, in-place convert it to a Doubly Linked List.

Print corner nodes of every level in binary tree

Given a binary tree, print corner nodes of every level in it.

Print Diagonal Traversal of Binary Tree

Given a binary tree, print all nodes for each diagonal having negative slope (\). Assume that the left and right child of a node makes 45 degree angle with the parent.

Perform vertical traversal of a binary tree

Given a binary tree, perform vertical traversal of it. In vertical traversal, we print nodes of a binary tree in vertical order by assuming that the left and right child of a node makes 45 degree angle with the parent.

Find the distance between given pairs of nodes in a binary tree

Given a binary tree, determine the distance between given pairs of nodes in it. Distance between two nodes is defined as the number of edges in shortest path from one node from other.

Print all paths from leaf to root node in a binary tree

Given a binary tree, write an recursive algorithm to print all paths from leaf to root node in a binary tree.

Find Lowest Common Ancestor (LCA) of Two Nodes in a Binary Tree

Given a binary tree and two nodes x and y in it, find lowest common ancestor (LCA) of x and y in it.

Check if a Binary Tree is Symmetric or not

Given a binary tree, write an efficient algorithm to check if it is symmetric binary tree or not. i.e. left subtree and right subtree are mirror images or each other.