Tree questions are very common at top tech company interviews.
Binary tree has an elegant recursive structure - Assuming you knew the solution to the left subtree and the right subtree, how could you combine the two results to give you the final solution?
- Understanding the tree properties, structure, implementation and tree traversals are important for solving problems in the tree.
- Identify patterns among problems: We can apply the idea of tree traversal for the solution of several problem in binary tree.
- Identifying the base case: This usually means solving the leaf node case (a leaf node has no left or right children) or the null case.
- Common operations: Insertion, Deletion, Searching, Traversal, Finding Internal Nodes, Finding leaf nodes, Finding height etc.