VOOZH about

URL: https://www.geeksforgeeks.org/dsa/check-two-trees-mirror-set-2/

⇱ Check if two trees are Mirror | Set 2 - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Check if two trees are Mirror | Set 2

Last Updated : 8 Mar, 2023

Given two Binary Trees, returns true if two trees are mirror of each other, else false. 

Mirror Tree : 

👁 Image


Previously discussed approach is here. 
 

Approach: Find the inorder traversal of both the Binary Trees, and check whether one traversal is reverse of another or not. If they are reverse of each other then the trees are mirror of each other, else not. 

Implementation


Output
Yes

Time Complexity: O(NlogN)

Auxiliary Space: O(N)

Comment