venkysmarty
venkysmarty

Reputation: 11431

number of leaves in a strict binary tree

I looking for derivation how we came to following result.

sum of 2 to power of i, as i goes from 0 to n => answer is given as (2 power of (n+1) -1).

Can any one show me how we achieved above result or to proper link where we have solution.

Thanks!

Upvotes: 2

Views: 253

Answers (2)

Chowlett
Chowlett

Reputation: 46667

Proof by induction.

Observe it's true for n=0 - sum0->0 = 1 = 2^1 - 1

Assume true for n = k-1, so sum[0->k-1] = 2^k - 1. Then sum[0->k] = sum[0->k-1] + 2^k = 2^k - 1 + 2^k = 2(2^k) - 1 = 2^(k+1) - 1.

Therefore true for all n.

Upvotes: 1

B. D
B. D

Reputation: 7823

It comes from the mathematical geometric progression.

If you want a clearer (more intuitive) explanation, you can read this nice explanation

Upvotes: 1

Related Questions