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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

The algorithm to delete an arbitrary node from a binary tree is deceptively<br />

complex, as there are many special cases. The algorithm used for the delete<br />

function splits it into two separate operations, searching and deletion. Once the<br />

node which is to be deleted has been determined by the searching algorithm, it<br />

can be deleted from the tree. The algorithm must ensure that when the node is<br />

deleted from the tree, the ordering of the binary tree is kept intact.<br />

1) The node to be deleted has no children.<br />

In this case the node may simply be deleted from the tree.<br />

before deletion of 2 after deletion of 2<br />

<br />

node to be deleted<br />

A tree may be defined as a finite set ‘T’ of one or more nodes such that there<br />

is a node designated as the root of the tree and the other nodes (excluding the<br />

root) are divided into n≥0 disjoint sets T1,T2,………….,Tn and each of these sets is<br />

a tree in turn.The trees T1,T2,…………..,Tn are called the sub‐trees or children of<br />

the root. Generally, it is a convention to draw root node at the top and let the<br />

tree grow downwards.<br />

FIGURE:‐<br />

2<br />

4 4<br />

7 7<br />

suresh<br />

sunita nikita<br />

Prepared By :­<br />

Er. Harvinder Singh<br />

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

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

Saved successfully!

Ooh no, something went wrong!