# Handshaking Lemma

An undirected graph is discussed by the handshake lemma. In every finite undirected graph, the odd degree is always contained by the even number of vertices. The degree sum formula shows the consequences in the form of handshaking lemma.

## Use of Handshaking Lemma in Tree data structure

Using the handshaking lemma, we can prove various interesting facts that are as follows:

1. The following property will always be true in a k-ary tree in which each and every node has its children as 0 or k.

Where

L shows the leaf nodes number

I shows the internal nodes number

Proof:

We have divided proof into the following two cases:

Case 1: In this case, we will prove that Root is a leaf. The tree is containing only one node. For a single node, the above formula is true as I = 0, L = 1.

Case 2: In this case, we will prove that Root is Internal Node. The root will always be an internal node if the tree is containing more than 1 node. For this case, we can use the Handshake lemma to prove the above formula. A tree can be expressed as an undirected acyclic graph.

Number of nodes in a tree: one can calculate the total number of edges, i.e.,

In this type of tree, except root all the internal nodes have k + 1 degree. Degree k is contained by the root, and degree 1 is contained by all the leaves. We will get the following relation when such a tree is applying handshaking lemma.

When we put the above term's value, we will get the following result:

We have seen that when we use handshaking lemma, the above property can be proved. Now we are going to learn another interesting property.

Alternative Proof: In this, we will not use Handshaking theory.

Since the tree has I internal nodes, and each internal node has K number of children. Therefore, the total number of children = k * I.

So we have internal nodes as I - 1, which are other node's children. It is excluded the root, i.e.,

Internal nodes are I - 1 out of k * I children. Therefore the leaves are described as (K*I - (I - 1)).

Hence

2. The following property number of leaf nodes in a binary tree is always one more than nodes with two children.

Where L shows the leaf node number

T shows the internal node's children, which have two children.

Proof: For this, we will assume T as the number of nodes which has two children. We have divided proof into the following three cases:

Case 1: The relationship is held by only one node as L=1, T =0

Case 2: When two children are contained by the root, then the root's degree is 2.

Sum of node's degree which has two children except root + sum of node's degree which has one children + sum of leave's degree + degree of root = 2 * (Number of nodes -1)

When we put the above term's value, we will get the following result:

When we cancel 25 from both sides, we will get the following result:

Case 3: When one child is contained by the root, then the root's degree is 1.

Sum of node's degree which has two children + sum of node's degree which has one children except root + sum of leave's degree + degree of root = 2 * (Number of nodes -1)

When we put the above term's value, we will get the following result:

When we cancel 25 from both the sides, we will get the following result:

Therefore, we have get T = L-1 in the above all three cases.

Using the Handshaking lemma, the two important properties of the tree have discussed.