# Category: Binary Tree

Binary Trees

## Print corner nodes of every level in binary tree

Given a binary tree, print corner nodes of every level in it.   Get great deals at Amazon

## 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.

## Print nodes in vertical order of a given Binary Tree (Vertical Traversal)

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 Vertical Sum in a given Binary Tree

Given a binary tree, print vertical sum of it. Assume, 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.

## Find ancestors of given node in a Binary Tree

Given a binary tree, find all ancestors of given node in it.

## Print all paths from root to leaf nodes in given binary tree

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

## 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.

## Inorder Tree Traversal | Iterative & Recursive

Given a binary tree, write iterative and recursive solution to traverse the tree using in-order traversal in C++ and Java.   Unlike linked lists, one-dimensional arrays and other linear data structures, which are traversed in linear order, trees may be traversed in multiple ways in depth-first order (pre-order, in-order, and post-order) or breadth-first order (level …

## Preorder Tree Traversal | Iterative & Recursive

Given a binary tree, write iterative and recursive solution to traverse the tree using pre-order traversal in C++ and Java.     Unlike linked lists, one-dimensional arrays and other linear data structures, which are traversed in linear order, trees may be traversed in multiple ways in depth-first order (pre-order, in-order, and post-order) or breadth-first order …

## Postorder Tree Traversal | Iterative & Recursive

Given a binary tree, write iterative and recursive solution to traverse the tree using post-order traversal in C++ and Java.     Unlike linked lists, one-dimensional arrays and other linear data structures, which are traversed in linear order, trees may be traversed in multiple ways in depth-first order (pre-order, in-order, and post-order) or breadth-first order …

## Determine if binary tree can be converted to another by doing any number of swaps of left and right child

Given a binary tree, write an efficient algorithm to determine if it can be converted to another binary tree by doing any number of swaps of its right and left branches.