10.09.2013 Views

1. Advanced Data Structure using C++

1. Advanced Data Structure using C++

1. Advanced Data Structure using C++

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

LECTURE NOTES OF ADVANCED DATA STRUCTURE (MT-CSE 110)<br />

The minimum and maximum height of a binary tree can be related to the<br />

number of nodes. Hmin = [log2 N] + 1<br />

H max = N<br />

Given the height of a binary tree, the minimum and maximum number of nodes<br />

in the tree can be calculated as Nmin = H; Nmax = 2 H ‐ 1<br />

A null tree is a tree with no nodes. The nodes at level 2 of a tree can all be<br />

accessed by following only two branches from the root. It stands to reason ,<br />

that the shorter we can make the tree, the easier it is to locate the desired node<br />

in the tree.<br />

This leads us to a very important characteristic of a binary tree, its balance. To<br />

determine if a tree is balanced, we calculate its balance factor. The balance<br />

factor of a binary tree is the difference in height between its left and right<br />

subtrees.<br />

B= Hleft – Hright<br />

A tree is balanced if its balance factor is zero and its subtrees are also balanced.<br />

A binary tree is balanced if the height of its subtrees differs by no more than<br />

one (its balanced factor is –1,0, or +1) and its subtrees are also balanced.<br />

A binary tree traversal requires that each node of the tree be processed once<br />

and only once in a predetermined sequence. There are two general approaches<br />

to the depth first and breadth first.<br />

The depth first traversal, the processing proceeds along a path from the root<br />

through one child to the most distant descendent of that first child before<br />

processing a second child. All of the descendents of a child are processed<br />

before the next child.<br />

Prepared By :­<br />

Er. Harvinder Singh<br />

Assist Prof., CSE, H.C.T.M (Kaithal) Page ‐ 181 ‐

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!