MCPcopy Create free account
hub / github.com/careercup/ctci / containsTree

Method containsTree

java/Chapter 4/Question4_8/Question.java:10–15  ·  view source on GitHub ↗
(TreeNode t1, TreeNode t2)

Source from the content-addressed store, hash-verified

8public class Question {
9
10 public static boolean containsTree(TreeNode t1, TreeNode t2) {
11 if (t2 == null)
12 return true; // The empty tree is a subtree of every tree.
13 else
14 return subTree(t1, t2);
15 }
16
17 /* Checks if the binary tree rooted at r1 contains the binary tree
18 * rooted at r2 as a subtree somewhere within it.

Callers 1

mainMethod · 0.95

Calls 1

subTreeMethod · 0.95

Tested by

no test coverage detected