Sir I don't get why u added n/2 in the recurrence relation. If I make the lower nodes pass the no. of leaves to it's parent besides calculating g(x) for itself, parent just has to find min out of two. so T(n)=2*T(n/2)+c & I'll get O(n). What's wrong in the following approach:
base case when node is a leaf node- g(x)=0 & pass 0 to it's parent
Let a node get n1, n2 from it's left, right subtrees. Calculate g(x) for itself but pass n1+n2 to it's parent. In case any one of n1, n2 is 0 then pass n1+n2+1. If both are 0s pass n1+n2+2.