the question is:
does B lie in the path from A to C below?
D
/ \
/ \
A M
/ \
/ \
B C
if yes, DFS suffices.
if no, it doesn't. LCA method would work in this case.
On Sun, Jan 9, 2011 at 10:44 PM, Algoose chase <[email protected]> wrote:
> @Juver++
> I am not sure if your input represents a path as asked in the problem.
> We typically think of a path within a binary tree as a downward path(from
> root to a leaf) thats not spread across different branches.
> Of course, if you consider that example as a valid case, then DFS wont work
> !
>
>
> On Sun, Jan 9, 2011 at 9:57 PM, nishaanth <[email protected]> wrote:
>
>> please describe the tree...give an elaborate explanation to your input....
>>
>>
>> On Sun, Jan 9, 2011 at 8:02 PM, juver++ <[email protected]> wrote:
>>
>>> x = 2, z = 3, y = 1. Does your algo give correct answer for this? node 1
>>> cannot be reached while DFS from node 2
>>>
>>>
>>> <https://lh3.googleusercontent.com/_qdJSDBXyZKE/TSi5XyCrEzI/AAAAAAAAARg/PB7anNiPA2c/graph.png>
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected]<algogeeks%[email protected]>
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>>
>> --
>> S.Nishaanth,
>> Computer Science and engineering,
>> IIT Madras.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected]<algogeeks%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<algogeeks%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
--
Man goes to doctor. Says he's depressed. Says life seems harsh and cruel.
Says he feels all alone in a threatening world where what lies ahead is
vague and uncertain. Doctor says "Treatment is simple. Great clown
Pagliacci is in town tonight. Go and see him. That should pick you up." Man
bursts into tears. Says "But, doctor...I am Pagliacci."
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.