First do a level order traversal.Let the result of level order traversal be
stored in a list l (ListTree l = new ArrayListTree).
Then we can do similar to level order once again.There will be two loops.
Outer loop will take an element from list l and treat it as root and the
inner loop will do
Space complexity- O(n), Time - O(n2).
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For
Gopinath's solution can be extended by adding one more logic. Do in-order
traversal, store it in an array or something. Keep resetting this
data-structure if you hit a right leaf or a non-increasing number.
Well we will need two such arrays, one for storing the current increasing
sequence and
@ above
ur soln ll fail in situation like
10
/ \
15 18
/\ / \
22 7 17 77
the inorder is
22 15 7 10 17 18 77
so the longest increasing sequence is 7-77
but this
Find the maximum size Binary search tree in a binary tree??
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to