Category Archives: Tree

Determine if two binary trees are identical

Two trees are identical when they have same data and there physical layout  is also same. To identify if two trees are identical, we need to traverse both trees simultaneously, and while traversing we need to compare data and children of the trees. Time Complexity: Complexity of the problem will be according to the tree Read More →

Write a C function to find the height or depth of a tree.

Write a C function to find the height or depth of a tree. Solution : The height can be found out recursively by calculating height of left sub tree tree and right sub tree.Height of tree would be the maximum  of height of left subtree and height of right subtree + 1.