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

Given a B‐Tree structure with an order of 5, we begin inserting 11,21,14 and 78.<br />

The first insert creates a node that becomes the root. The next three inserts<br />

simply place the data in the node in ascending key sequence. (a) When we try to<br />

insert 97, we discover that the node if full. We therefore create a new right<br />

subtree and move the larger half of the data to it, leaving the rest of the data in<br />

the original node (b).<br />

After creating the new node, we insert the median value data (21) into the<br />

parent of the original node. Because the original node was a root, we create a<br />

new root and insert 21 into it.<br />

Algorithms<br />

Search<br />

Searching is similar to searching a binary search tree. Starting at the root, the<br />

tree is recursively traversed from top to bottom. At each level, the search<br />

chooses the child pointer (subtree) whose separation values are on either side<br />

of the search value.Binary search is typically (but not necessarily) used within<br />

nodes to find the separation values and child tree of interest.<br />

Insertion<br />

In order to insert a key into a B‐tree, first a B‐Tree search is performed to find<br />

the correct location for the key. Then the key is inserted. Note that a node<br />

usually may have a space available for another key and pointer. However, the<br />

node may be already full and cannot accommodate another key. In that case,<br />

Prepared By :­<br />

Er. Harvinder Singh<br />

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

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

Saved successfully!

Ooh no, something went wrong!