For a complete binary tree with n nodes, how many nodes are leaf nodes?

Amit Jain picture Amit Jain · Nov 9, 2014 · Viewed 23.1k times · Source

One of the answers in our powerpoint says it is n/2 leaves, but I am seeing another answer which says (n+1)/2. I was wondering which one is correct if any, and why?

Answer

Robert Bain picture Robert Bain · Nov 9, 2014

In the simplest case a binary tree with a root node, a left and a right has 3 nodes, two of which are leaf nodes. It's (n+1)/2.