A symmetric tree is a mirror image of itself around the root node. A recursive or iterative approach can determine whether or not a binary tree is symmetric. Let’s take a look at the examples of Symmetric Tree and determine whether they’re true or false.
Given a binary tree, check whether it is a mirror of itself i.e. symmetric around its center.
1
Learn how to Construct the Binary Tree with the inorder and preorder traversal.
0
Learn how to solve the Mirror Image of Binary Tree problem.
0
Know how to Validate a Binary Search Tree.
Following is the code to solve the symmetric tree problem.
/*
Asymptotic complexity in terms of the number of nodes ( = `n`) and the height ( = `h`) of the tree rooted at `root`:
* Time: O(n).
* Auxiliary space: O(h).
* Total space: O(n).
*/
// Helper function which returns true if trees with roots as root1 and root2 are mirror images.
bool check_if_mirror(BinaryTreeNode* root1, BinaryTreeNode* root2){
 if (root1 == NULL && root2 == NULL){
   return true;
 }
 if(root1 == NULL || root2 == NULL){
   return false;
 }
 if (root1->value == root2->value){
   return check_if_mirror(root1->left, root2->right) && check_if_mirror(root1->right, root2->left);
 }
 return false;
}
bool check_if_symmetric(BinaryTreeNode *root) {
 return check_if_mirror(root, root);
}
â€Find out how to Build a Balanced BST from a Sorted Array.
We hope that these solutions to the Symmetric Tree problem will help you level up your coding skills. Data structures are the foundation of programming languages, and the Binary Search Tree is a tree that allows for fast search, insert, and delete operations on sorted data. It also allows you to find the item that is closest to you. Routing Tables, Sorting, Decision Trees, and Data Compression are just a few of the many applications of Symmetric Tree.
Because of the widespread use of Tree Data Structure, companies such as Amazon and Zomato include Symmetric Tree interview questions and other Binary Tree Data Structure problems in their tech interviews.
If you are preparing for a tech interview at FAANG or any other Tier-1 tech company, register for Interview Kickstart’s FREE webinar to understand the best way to prepare.
Interview Kickstart offers interview preparation courses taught by FAANG+ tech leads and seasoned hiring managers. Our programs include a comprehensive curriculum, unmatched teaching methods, FAANG+ instructors, and career coaching to help you nail your next tech interview.
We offer 17 interview preparation courses, each tailored to a specific engineering domain or role, including the most in-demand and highest-paying domains and roles, such as:
To learn more, register for the FREE webinar.
The 11 Neural “Power Patterns” For Solving Any FAANG Interview Problem 12.5X Faster Than 99.8% OF Applicants
The 2 “Magic Questions” That Reveal Whether You’re Good Enough To Receive A Lucrative Big Tech Offer
The “Instant Income Multiplier” That 2-3X’s Your Current Tech Salary
The 11 Neural “Power Patterns” For Solving Any FAANG Interview Problem 12.5X Faster Than 99.8% OF Applicants
The 2 “Magic Questions” That Reveal Whether You’re Good Enough To Receive A Lucrative Big Tech Offer
The “Instant Income Multiplier” That 2-3X’s Your Current Tech Salary
Just drop your name and email so we can send your Power Patterns PDF straight to your inbox. No Spam!
By sharing your contact details, you agree to our privacy policy.
Time Zone: Asia/Dhaka
We’ve sent the Power Patterns PDF to your inbox — it should arrive in the next 30 seconds.
📩 Can’t find it? Check your promotions or spam folder — and mark us as safe so you don’t miss future insights.
We’re hosting a private session where FAANG insiders walk through how they actually use these Power Patterns to crack interviews — and what sets top performers apart.
🎯 If you liked the PDF, you’ll love what we’re sharing next.
Time Zone: