Sunday, October 21, 2012

Binary Tree Comparison

Problem:
Given two binary trees, compare if they are the same. If yes, return true, otherwise return false.

Analysis:
This is a very common programming interview question. Not that hard but it's very good to test the idea of recursion. Also, there are some edge cases one needs to consider.

Complexity:
Since it's a binary tree, should consider average case and worst case.
Balanced or unbalanced?

Solution:

No comments:

Post a Comment