Can somebody help me in understanding the below algorithm of how to find the maximum difference between any two nodes in a Binary Tree.
http://www.geeksforgeeks.org/maximum-difference-between-node-and-its-ancestor-in-binary-tree/
I'm not understanding why they are trying to get minimum value from left subtree and right subtree when in actual we want max difference & not min difference. So, Shouldn't we be getting the max difference recursively from left & right subtrees & use it to calculate our result?
Thanks in advance !!
minimum
andmaximum
. The result will bemaximum - minimum
. – SashaMN