Identical Binary Trees

Question : WAP to find out if two binary tress are identical or not in O(n) time complexity.

Solution : The problem is solved in recursive way.

Algorithm : Step 1 : If both the trees are empty ,then return true. Step 2 : Recursively traverse and check equality of left sub-tree,right sub-tree and data of each node of both trees.Return the result. Step 3 : If one tree is empty and other is non-empty return false.

About the Author

Dear Friends,
I am A.K.M. .This online journal ai1tutorial.com is a humble effort from my side to all students and professionals who want to learn computer science related technologies.I am not a professional blogger and I write posts in this blog only in my leisure time.I may not be 100% perfect in all my posts,but your review comments can surely help me to make it 100% perfect.