Binary Tree: Interview Questions and Practice
Problems
1. Inorder Tree Traversal
2. Preorder Tree Traversal
3. Postorder Tree Traversal
4. Check if two binary trees are identical or not
5. Print bottom view of a binary tree
6. Print top view of a binary tree
7. In-place convert a binary tree to its sum tree
8. Determine whether the given binary tree nodes are
cousins of each other
9. Print cousins of a given node in a binary tree
10. Check if a binary tree is a sum tree or not
11. Combinations of words formed by replacing given
numbers with corresponding alphabets
12. Determine whether a binary tree is a subtree of another
binary tree
13. Find the diameter of a binary tree
14. Check if a binary tree is symmetric or not
15. Convert a binary tree to its mirror
16. Determine if a binary tree can be converted to another
by doing any number of swaps of children
17. Find the Lowest Common Ancestor (LCA) of two nodes
in a binary tree
18. Print all paths from the root to leaf nodes of a binary
tree
19. Find ancestors of a given node in a binary tree
20. Find distance between given pairs of nodes in a binary
tree
21. Find the diagonal sum of a binary tree
22. Sink nodes containing zero to the bottom of a binary
tree
23. Convert a binary tree to a full tree by removing half
nodes
24. Truncate a binary tree to remove nodes that lie on a
path having a sum less than `k`
25. Find maximum sum root to leaf path in a binary tree
26. Check if a binary tree is height-balanced or not
27. Convert binary tree to Left-child right-sibling binary
tree
28. Print all paths from leaf to root node of a binary tree
29. Iteratively print the leaf to root path for every leaf node
in a binary tree
30. Build a binary tree from a parent array
31. Find all nodes at a given distance from leaf nodes in a
binary tree
32. Count all subtrees having the same value of nodes in a
binary tree
33. Find the maximum difference between a node and its
descendants in a binary tree
34. Find the maximum sum path between two leaves in a
binary tree
35. Construct a binary tree from inorder and preorder
traversal
36. Construct a binary tree from inorder and postorder
traversals
37. Construct a binary tree from inorder and level order
sequence
38. Construct a full binary tree from the preorder sequence
with leaf node information
39. Construct a full binary tree from a preorder and
postorder sequence
40. Find postorder traversal of a binary tree from its
inorder and preorder sequence
41. Set next pointer to the inorder successor of all nodes in
a binary tree
42. Find preorder traversal of a binary tree from its
inorder and postorder sequence
43. Find the difference between the sum of all nodes
present at odd and even levels in a binary tree
44. Clone a binary tree with random pointers
45. Threaded Binary Tree — Overview and
Implementation
46. Determine if a binary tree satisfies the height-balanced
property of a red–black tree
47. Construct an ancestor matrix from a binary tree
48. Find all possible binary trees having the same inorder
traversal
49. Perform boundary traversal on a binary tree
50. Check if each node of a binary tree has exactly one
child
51. Evaluate a Binary Expression Tree
52. Construction of an expression tree
53. Fix children-sum property in a binary tree
54. Maximum path sum in a binary tree
55. Create a mirror of an m–ary tree
56. Print a two-dimensional view of a binary tree
57. Construct a binary tree from an ancestor matrix
58. Determine whether a given binary tree is a BST or not
59. Find inorder successor for the given key in a BST
60. Fix a binary tree that is only one swap away from
becoming a BST
61. Find the size of the largest BST in a binary tree
62. Print binary tree structure with its contents in C++
63. Maximum Independent Set Problem
64. Huffman Coding Compression Algorithm
65. Construct a Cartesian tree from an inorder traversal
66. Calculate the height of a binary tree with leaf nodes
forming a circular doubly linked list
67. Link nodes present in each level of a binary tree in the
form of a linked list
68. Convert a ternary tree to a doubly-linked list
69. Extract leaves of a binary tree into a doubly-linked list
70. Find the vertical sum of a binary tree
71. In-place convert a binary tree to a doubly-linked list
72. Check whether the leaf traversal of given binary trees is
the same or not
73. Efficiently print all nodes between two given levels in a
binary tree
74. Calculate the height of a binary tree
75. Delete a binary tree
76. Level order traversal of a binary tree
77. Spiral order traversal of a binary tree
78. Reverse level order traversal of a binary tree
79. Print all nodes of a perfect binary tree in a specific
order
80. Print left view of a binary tree
81. Find the next node at the same level as the given node
in a binary tree
82. Check if a binary tree is a complete binary tree or not
83. Print diagonal traversal of a binary tree
84. Print corner nodes of every level in a binary tree
85. Invert Binary Tree
86. Convert a binary tree into a doubly-linked list in spiral
order
87. Check if a binary tree is a min-heap or not
88. Invert alternate levels of a perfect binary tree
89. Perform vertical traversal of a binary tree
90. Compute the maximum number of nodes at any level
in a binary tree
91. Print right view of a binary tree
92. Find the minimum depth of a binary tree
93. Depth-First Search (DFS) vs Breadth-First Search
(BFS)
94. Print nodes of a binary tree in vertical order