Printing border nodes of Binary Tree

Given a Binary tree, Write code to print all the boundary nodes in counter clockwise order. For example, for the below binary tree, The output […]

Null pointers in a Binary tree

Given a Binary Tree with n Nodes (you may arrange these nodes any way you want to). How many NULL pointers will be there ? […]

Print edge nodes (boundary nodes) of a Binary Tree

Given a Binary Tree. Write code to print the boundary nodes of the Tree. For example, if the Binary tree is __30__ / \ / […]

Print all nodes at distance k from root of a Binary Tree

Given a Binary Tree and a positive integer ‘k’, write code which will print all the nodes which are at distance ‘k’ from the root. […]

Check if a Binary Tree is Binary Search Tree

Given a Binary Tree, write code to check if it is Binary Search Tree or not ? Binary search tree is a binary tree with […]

Convert a Binary Tree to Binary Search Tree

Given a Binary Tree, write code to convert it to Binary Search Tree such that the structure of the tree remains the same. For example: […]

Lowest Common Ancestor in Binary Search Tree

In a Binary Search Tree, you are given the values of two nodes. Write a code which will return the Lowest Common Ancestor of both […]

Print all possible root-to-leaf paths in a binary tree

Given a Binary Tree, write code to print all root-to-leaf paths possible in the tree. For Example, For the Binary Tree given on the right […]

Number of nodes in a binary tree

Write a function which will return the total number of nodes in a Binary tree. For example, the Binary tree on the right has 7 […]

check if all nodes of a tree has only one child

Given the PreOrder traversal of a binary search tree (in the form of a tree), check if all the nodes (except the last) of the […]