Let
No of flips reqd  = solve(N, V)
L=left subtree.
R = right subtree
N = root node.

If V=0, then
   only problem is when L = 1 and R=1.  (otherwise atmax changing the root
node will do)
   then ans = min(solve(L, 0), solve(R,0)) + (R=AND)?0:1

If V=1 then
   only problem is when L=0 and R=0
   similarly dealt.

If V=something else
   output -1

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to