Is there a specific way to handle equations to convert it into such a form that it gives right value for any value substituted?

19 Views Asked by At

I was trying to find relation between total number of nodes in a complete binary tree and the leaf nodes. Note that a complete binary tree is a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possible.While working it out I got the equation $l=n/2$, where $l$ is the number of leaf nodes and $n$ is the total number of nodes in complete binary tree, if $n$ is even. When $n$ is odd, $l=(n-1)/2$. Now is there a specific way to make these equations into a single equation using floor and ceiling so that it can handle both the cases when n is even or odd. The only way I can think of by plugging the values and observing that it is actually the $\lfloor n/2\rfloor$.