[algogeeks] Re: T1, with millions of nodes, and T2, with hundreds of nodes. Create an algorithm to decide if T2 is a subtree of T1.

2012-10-28 Thread vikas
one optimization could be: Inorder(big).subString(inorder(small)) == true , then only execute this logic. On Friday, 26 October 2012 02:54:14 UTC+5:30, Don wrote: If T1 is a balanced tree with 50 million nodes, where the value of each node is 42, and T2 is a tree with 500 nodes with all

[algogeeks] Re: T1, with millions of nodes, and T2, with hundreds of nodes. Create an algorithm to decide if T2 is a subtree of T1.

2012-10-25 Thread Don
If T1 is a balanced tree with 50 million nodes, where the value of each node is 42, and T2 is a tree with 500 nodes with all values equal 42 except the rightmost node which is 43, these approaches will take a very long time. Any ideas on how to improve performance in such cases? Don On Oct 25,