I am not sure you mentioned the problem statement correctly , anyways
here goes my solution .
recurse(int valuerequired , node * n , int value_now , int steps)
{
if(node==NULL)
return 0;
else if(valuerequired== value_now)
return steps;
//we need to see the minimum number of gates to be flipped in order
to achieve the desired answer . We can flip this gate , the gate ,
the gate left to it , and the gate right to it .
// thus the answer is
else return min(recurse(valuerequired , node->left ,
value_now , steps+1) , recurse(valuerequired , node->right ,
value_now , steps+1))
}
/*
I did not quite understand the question though , can you provide with
an example ?
*/
--
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.