DEV Community

Jayaprasanna Roddam
Jayaprasanna Roddam

Posted on • Edited on

DSA: Tree - questions

1. Tree Basics and Traversals
·      Implement a Binary Tree
·      Preorder Traversal (Recursive and Iterative)
·      Inorder Traversal (Recursive and Iterative)
·      Postorder Traversal (Recursive and Iterative)
·      Level Order Traversal (BFS)
·      Reverse Level Order Traversal
·      Spiral/Zigzag Level Order Traversal
·      Boundary Traversal of a Binary Tree
·      Diagonal Traversal of a Binary Tree
·      Vertical Order Traversal of a Binary Tree
 
 2. Binary Tree Construction Problems
·      Construct a Binary Tree from Inorder and Preorder Traversal
·      Construct a Binary Tree from Inorder and Postorder Traversal
·      Construct a Binary Tree from Level Order and Inorder Traversal
·      Construct a Special Tree from Inorder Traversal (Tree with Only One Child Nodes)
·      Construct a Full Binary Tree from Preorder and Postorder Traversal
·      Construct a Binary Tree from its Mirror Image
·      Convert a Binary Tree to its Mirror Tree
·      Convert a Binary Tree to a Doubly Linked List
·      Construct a Threaded Binary Tree
·      Build a Tree from Inorder and Level Order Traversal
 
 3. Tree Properties and Analysis
·      Find the Height of a Binary Tree
·      Find the Depth of a Given Node
·      Check if a Tree is Symmetric
·      Check if Two Trees are Identical
·      Diameter of a Binary Tree
·      Check if a Binary Tree is Balanced (Height Balanced)
·      Check if a Binary Tree is a Sum Tree
·      Maximum Path Sum in a Binary Tree
·      Check if a Binary Tree is Perfect
·      Check if a Binary Tree is Complete
 
 4. Tree Modification and Manipulation
·      Convert a Binary Tree to a Sum Tree
·      Convert a Binary Tree to a Child-Sum Property Tree
·      Convert a Binary Tree to a Doubly Linked List
·      Convert a Binary Tree into a Circular Doubly Linked List
·      Convert a Binary Tree to a Threaded Binary Tree
·      Flatten a Binary Tree to a Linked List
·      Convert a Binary Tree to a List of Levels
·      Convert a Binary Tree to an Inverted Tree
·      Add All Greater Values to Every Node in a Binary Search Tree (BST)
·      Merge Two Binary Trees
 
 5. Binary Search Tree (BST) Problems
·      Insert a Node in a BST
·      Delete a Node in a BST
·      Search for a Node in a BST
·      Find the Minimum and Maximum Value in a BST
·      Find the Inorder Successor and Predecessor in a BST
·      Check if a Given Tree is a BST
·      Convert a BST to a Greater Sum Tree
·      Lowest Common Ancestor (LCA) in a BST
·      Check if a BST is Height Balanced
·      Merge Two BSTs into a Balanced BST
 
 6. Tree Views
·      Left View of a Binary Tree
·      Right View of a Binary Tree
·      Top View of a Binary Tree
·      Bottom View of a Binary Tree
·      Print All Leaf Nodes from Left to Right
·      Print All Leaf Nodes from Right to Left
·      Boundary View of a Binary Tree
·      Print the Longest Path in a Binary Tree
·      Print Nodes at Distance K from the Root
·      Print Nodes at Distance K from a Given Node
 
7. Tree Recursive Problems
·      Print All Ancestors of a Given Node
·      Print All Paths from Root to Leaf
·      Print the Path from Root to a Given Node
·      Find the Kth Smallest Element in a BST
·      Find the Kth Largest Element in a BST
·      Find the Lowest Common Ancestor (LCA) in a Binary Tree
·      Count Leaf Nodes in a Binary Tree
·      Count Non-Leaf Nodes in a Binary Tree
·      Count Nodes with Exactly One Child in a Binary Tree
·      Count Nodes with Two Children in a Binary Tree
 
 8. Tree Algorithms and Techniques
·      Morris Traversal (Inorder and Preorder without Recursion and Stack)
·      Threaded Binary Tree Traversal
·      Finding the Maximum Width of a Binary Tree
·      Serialize and Deserialize a Binary Tree
·      Check if a Binary Tree is Subtree of Another Tree
·      Find the Largest BST in a Binary Tree
·      Find All Nodes at Distance K in a Binary Tree
·      Convert a Binary Tree to a Circular Doubly Linked List
·      Inorder Successor in a BST without Using Parent Pointer
·      Flatten a Binary Tree into a List of Levels
 
 9. Tree-Based Dynamic Programming
·      Maximum Path Sum in a Binary Tree
·      Maximum Sum of Nodes without Adjacent Nodes
·      Diameter of a Binary Tree using DP
·      Largest Independent Set Problem in a Binary Tree
·      House Robber Problem (Binary Tree Version)
·      Longest Path Between Any Two Nodes
·      Count Number of Subtrees with a Given Sum
·      Find the Longest Consecutive Sequence Path in a Binary Tree
·      Check if a Tree can be Partitioned into Two Trees with Equal Sum
·      Count Number of Unique BSTs (Catalan Number)
 
 10. Tree Miscellaneous Problems
·      Check if a Tree is a Mirror of Itself (Symmetric)
·      Convert Sorted Array to a Balanced BST
·      Convert Sorted Linked List to a Balanced BST
·      Print Nodes in the Topological Order of a Binary Tree
·      Sum of All Nodes in a Binary Tree
·      Sum of All Left Leaves in a Binary Tree
·      Sum of All Right Leaves in a Binary Tree
·      Print the Vertical Sum of a Binary Tree
·      Find All Duplicate Subtrees in a Binary Tree
·      Find the Maximum Sum Subtree in a Binary Tree

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay