Given a tree of N nodes number 0 to N-1.Each node has a binary value i.e, 0 or 1 denoted by integer array. The beauty of ith node is (2^i)*A[i]. Total beauty of tree is sum of beauty of each node.
The tree is acceptable only if total beauty is 2^N-1 or 0.
find Minimum number of operations to make the tree acceptable:
In each operation select any node x and called flip(x).
flip(x):
for(v:0 to N-1)
{
if(all node in path from x to v have same values)
{ a[v] = 1 - a[v];
}