finding the deepest common node of two nodes

It’s the most curious and excellent problem.

at first i thought to form a brute-force one which could have taken

O(nlog(n)2)

which i trash it as usually. But now i’m feeling that brute-force one would be more difficult to code than this efficient and easy one!!!!

we have to use a dummy null tree in the global space to overcome both the const return compilation error and local var return compilation error

 

PS: error handling is ignored i.e if b is in the path or if a or b or both are absent in the tree

PPS: we just have to embed an if condition and make the end product to be returned as NULL from the d_c_n for all errors

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s