Interview Questions

Determine if binary tree is a subtree of a larger binary tree

In a previous algorithm tutorial we discussed how to traverse a tree using different algorithms. Now we'll solve a popular tree algorithm question of determining if a binary tree is a subtree within a larger tree.
In the picture below, you can see that the tree on the left is contained within the tree on the right, underneath the gray node with a value of 10.

You need to be a premium member to see the rest of this question and code.

mrdaniel
published this on 6/11/16 **|**

Login to submit a comment