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 node is split into two nodes, with half the key values and pointer going into<br />

one node while the other half going into another node.<br />

These twin nodes have the same parent, which is modified for the additional<br />

key value and pointer. In the worst case, the splitting procedure may need to be<br />

carried all the way up the root of the tree. In that case, the height of the tree<br />

increases by one level. This insertion procedure is implemented as a recursion<br />

since the splitting procedure is the same, irrespective of the level.<br />

A B Tree insertion example with each iteration.<br />

All insertions start at a leaf node. To insert a new element<br />

Search the tree to find the leaf node where the new element should be added.<br />

Insert the new element into that node with the following steps:<br />

<strong>1.</strong> If the node contains fewer than the maximum legal number of elements,<br />

then there is room for the new element. Insert the new element in the<br />

node, keeping the node's elements ordered.<br />

2. Otherwise the node it is full, so evenly split it into two nodes.<br />

<strong>1.</strong> A single median is chosen from among the leaf's elements and the<br />

new element.<br />

Prepared By :­<br />

Er. Harvinder Singh<br />

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

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

Saved successfully!

Ooh no, something went wrong!