Rooting the Concepts of Trees


Recently, I completed the Tree Data Structure from Striver’s A2Z DSA Series. This wasn’t just a milestone in my DSA journey,it significantly strengthened my understanding of recursion and recursive problem-solving. I chose to start Trees right after completing stacks and queues because I felt my recursion fundamentals needed improvement. Trees, being inherently recursive, provided a perfect opportunity to sharpen this skill.
Through this journey, I tackled problems across various patterns including basic traversals (inorder, preorder, postorder), level-order traversal using queues, and even Morris Traversal, which introduced me to the concept of threaded binary trees for space optimization. I worked on problems based on root-to-node paths, view-based traversals (like vertical, top, and bottom views), and tree construction from preorder/inorder and postorder/inorder sequences. Each category helped me develop a deeper intuition about how recursion flows, especially the importance of base cases and parameter handling in recursive calls.
A major portion of my learning came from Binary Search Tree (BST) problems. Solving questions like validating a BST, constructing a BST from preorder, and deleting a node from a BST gave me confidence in manipulating tree structures effectively. I particularly enjoyed working on the “Delete Node in BST” problem, which helped me understand edge-case handling and subtree management. The “Lowest Common Ancestor” question helped me distinguish between the approaches for a Binary Tree versus a BST, and showed me how leveraging BST properties can reduce time complexity from O(n) to O(h).
One of my biggest takeaways was how in-order traversal acts as a key tool in solving many BST-related problems due to its naturally sorted nature. I also appreciated the role of iterative solutions and the use of stacks, especially in questions like BST Iterator and Two Sum IV. Initially, I struggled with the recursion-heavy problems, but after following Striver’s clear explanations and repeatedly practicing, recursion became one of my strengths.
Constructing binary trees from given traversals was another area that challenged and ultimately improved my understanding of index boundaries, recursive logic, and tree reconstruction. These problems required precision in handling ranges and were some of the most satisfying problems to solve. Additionally, I learned how to approach problems with a mindset suited for real-world applications, especially in handling larger test cases and optimizing for edge scenarios.
Overall, this module has improved my logical reasoning, recursive thinking, and confidence in solving medium to hard-level tree problems. My favorite problems from this module were “Delete Node in BST”, “Lowest Common Ancestor”, and “Construct Binary Tree from Preorder and Inorder Traversal”. With this foundation, I am now excited to start the Graph DS.
Subscribe to my newsletter
Read articles from Sai Surve directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
