# Can you add up all the nodes of a special binary tree in polynomial time, in respect to the number of levels?

Let's say you have a binary tree defined by a group $$S=\{a:[5,6],b:[7,67],c:[45,12],...\}$$ (this group is just an example). The binary tree is constructed so that there are two starting parent nodes, $$a$$ and $$a$$. Each of those nodes have two child nodes $$b$$ and $$b$$. Each of those nodes ($$b$$ and $$b$$ from both $$a$$ and $$a$$) have two child nodes, $$c$$ and $$c$$, and so on and so on. To evaluate such a tree, you start at the bottom of the tree, add up the two leaf nodes in each of the last parent nodes, and multiply that by its parent node. This is now the new value of the parent nodes. This process is repeated upwards until you do $$a(b+b)+a(b+b)$$ (remember that $$b$$ and $$b$$ are no longer $$7$$ and $$67$$, respectively at this point). Can you do this evaluation in polynomial time, in respect to the number of levels of the tree?

Follow up: Can it still be done in polynomial time if some of the leaf nodes are missing?

EDIT: Here is a picture with what I mean: No. A complete binary tree has $$\ell$$ levels and about $$2^\ell$$ nodes. Any algorithm must examine all nodes to get the correct answer, so the running time has to be exponential in the number of levels.