File tree 1 file changed +7
-1
lines changed
src/_DataStructures_/Trees/BinaryTree/check-binary-tree-subtree-another-binary-tree
1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change
1
+ // Check if a binary tree is subtree of another binary tree
2
+ // Root of the source tree and the tree to be matched are provided in the parameters.
3
+ // Return true/false based on whether or not the given tree is the subtree of the source tree
4
+ // Time complexity : O(m*n) m is the number of nodes of the original tree,
5
+ // n is the number of nodes in the tree to be matched
6
+
1
7
function areIdentical ( rootOfOriginalTree , rootOfMatchingTree ) {
2
8
if ( rootOfOriginalTree === null && rootOfMatchingTree === null ) {
3
9
return true ;
4
10
}
5
11
6
- if ( Roo1 === null || rootOfMatchingTree === null ) {
12
+ if ( rootOfOriginalTree === null || rootOfMatchingTree === null ) {
7
13
return false ;
8
14
}
9
15
You can’t perform that action at this time.
0 commit comments