Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Claim: A non-empty binary tree T of height h(T) has at most 2 h(T) + 1 – 1 nodes.

Let, N(T) be the number of nodes in a non-empty binary tree, and P be the proposition
we want to prove.
Inductive base: If T consists of a single root node r, (base case for a non-empty
binary tree), then according to the definition of the height of a binary tree, h(T) = 0.
Therefore, N(r) = 1 ≤ 20+1 – 1 ≤ 2h(r)+1 – 1
So, P(r) holds.
Inductive hypothesis: In the recursive step of the definition of a non-empty binary
tree, T may consist a root node r pointing to 1 or 2 non-empty binary trees T L and TR.
Without loss of generality, we can assume that both TL and TR are defined, and we
assume P(TL) and P(TR).
Also, let us assume h(TL)≥h(TR), without loss of generality, because the case of
h(TL)<h(TR) is symmetric to the case of h(TL)>h(TR), according to the definition of a
non-empty binary tree.
Inductive step: We have to prove that P(T) must hold.
h(T) = max(h(TL), h(TR)) + 1 [Definition of the height of a non-empty binary tree]
⇒h(T) = h(TL)+1 [h(TL)≥h(TR)]
Now,
N(T) = 1 + N(TL) + N(TR) [Definition of a non-empty binary tree]
⇒N(T) ≤ 1 + 2h(TL)+1 – 1 + 2h(TR)+1 – 1 [P(TL) and P(TR)]
⇒N(T) ≤ 2h(TL)+1 + 2h(TR)+1 – 1
⇒N(T) ≤ 2h(TL)+1 + 2h(TL)+1 – 1 [h(TL)≥h(TR), so 2h(TL)+1≥2h(TR)+1]
⇒N(T) ≤ 2(2h(TL)+1) – 1
⇒N(T) ≤ 2(2h(T)) – 1 [h(T) = h(TL) + 1]
⇒N(T) ≤ 2h(T) + 1 – 1

So, P(T) holds.


Let, ∑ = {a, b} be an alphabet. We define a language L as follows:
Base case: Empty string, ε ∈ L.
Recursive step: If x ∈ L, axa ∈ L and bxb ∈ L.
Claim: ∀w ∈ L, the number of characters in w is even.
Note: The length of a string w, len(w) is defined as follows:
Base case: len(ε) = 0.
Recursive step: If w ∈ ∑* and x ∈ ∑, then len(wx) = len(w) + 1.
The number of the characters in a string can alternatively be stated as its length.
Let, P be the proposition we want to prove.
Inductive base: In the base case definition of L, we have that ε ∈ L.
Now, len(ε) = 0 = 2 × 0
Since len(ε) can be written as 2×k for an integer k, therefore len(ε) is even.
So, P({ε}) holds.
Inductive hypothesis: The inductive definition of L successively builds sets L’ from
previous versions of L. We assume that ∃L’ : |L’|≥1 and P(L’).
Inductive step: We will prove that P(L’ ∪ {axa|x ∈ L’} ∪ {bxb|x ∈ L’}) holds.
Let, x0 be an arbitrarily selected element of L’. From the inductive hypothesis, we know
that the length of x0 is even.
Let, len(x0) = 2 × k, for some arbitrary integer k.
By definition, len(ax0a) = 1 + 2×k + 1 = 2×k + 2 = 2 × (k+1)
Similarly, len(bx0b) = 1 + 2×k + 1 = 2×k + 2 = 2 × (k+1)
Therefore, both ax0a and bx0b have even lengths.
This shows that P({x0}).
Since x0 was arbitrarily selected within L’, P(L’ ∪ {axa|x ∈ L’} ∪ {bxb|x ∈ L’}) holds.

You might also like