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 />

For any non‐empty binary tree with n0 leaf nodes and n2 nodes of degree 2, n0 =<br />

n2 + <strong>1.</strong><br />

Definitions for rooted trees:<br />

A binary tree is a connected acyclic graph such that the degree of each vertex is<br />

not more than three. It can be shown that in any binary tree, there are exactly<br />

two or more nodes of degree one than there are of degree three, but there can<br />

be any number of nodes of degree two. A rooted binary tree is such a graph that<br />

has one of its vertices of degree not more than two singled out as the root.<br />

1) A directed edge refers to the link from the parent to the child (the<br />

arrows in the picture of the tree).<br />

2) The root node of a tree is the node with no parents. The is at the most<br />

one root node in a rooted tree.<br />

3) A leaf node has no children.<br />

4) The depth of a node n is the length of the path from the root to the<br />

node. The set of all nodes at a given depth is sometimes called a level<br />

of the tree. The root node is at depth zero.<br />

5) The height of a tree is the length of the path from the root to the<br />

deepest node in the tree. A (rooted) tree with only a node (the root)<br />

has a height of zero.<br />

6) Siblings are nodes that share the same parent node.<br />

7) In‐degree of a node is the number of edges arriving at that node.<br />

8) Out‐degree of a node is the number of edges leaving that node.<br />

Complete binary tree<br />

A tree consist of a finite set of elements called nodes and a finite set of directed<br />

lines called branches that connect the nodes.<br />

Prepared By :­<br />

Er. Harvinder Singh<br />

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

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

Saved successfully!

Ooh no, something went wrong!