Binary Tree – Interview Questions and Practice Problems

A Binary Tree is a tree data structure in which each node has at most two children, which are referred to as the left child and the right child, and the topmost node in the tree is called the root.

 
In this post, we have listed out commonly asked interview questions that use binary tree:

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

 
Also See:

Binary Search Tree (BST) – Interview Questions and Practice Problems

Rate this post

Average rating 4.9/5. Vote count: 104

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Tell us how we can improve this post?

Thanks for reading.

To share your code in the comments, please use our online compiler that supports C, C++, Java, Python, JavaScript, C#, PHP, and many more popular programming languages.

Like us? Refer us to your friends and support our growth. Happy coding :)


guest
0 Comments
Inline Feedbacks
View all comments
Do NOT follow this link or you will be banned from the site!