Given two binary trees with head reference as T and S having at most N nodes. The task is to check if S is present as subtree in T. A subtree of a tree T1 is a tree T2 consisting of a node in T1 and...


Given two binary trees with head reference as
T

and
S
having at most
N
nodes. The task is to check if S is present as subtree in T.
A subtree of a tree T1 is a tree T2 consisting of a node in T1 and all of its descendants in T1


You don't need to read input or print anything. Your task is to complete the
function isSubtree()that takes root node of S and T as parameters
and
returns 1
if S is a subtree of T else
0.





Expected Time Complexity:O(N).

Expected Auxiliary Space:O(N).



Constraints:

1 <= number="" of="" nodes=""><=>5

1 <= value="" of="" nodes=""><=>4




Jun 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here