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.

Search<br />

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

The algorithm to perform a search for a record r follows pointers to the correct<br />

child of each node until a leaf is reached. Then, the leaf is scanned until the<br />

correct record is found (or until failure).<br />

Function search (record r)<br />

u := root<br />

While (u is not a leaf) do<br />

Choose the correct pointer in the node<br />

move to the first node following the pointer<br />

u := current node<br />

scan u for r<br />

This pseudocode assumes that no repetition is allowed.<br />

Insertion<br />

• do a search to determine what bucket the new record should go in<br />

• if the bucket is not full, add the record.<br />

• otherwise, split the bucket.<br />

• allocate new leaf and move half the bucket's elements to the new bucket<br />

• insert the new leaf's smallest key and address into the parent.<br />

• if the parent is full, split it also<br />

• now add the middle key to the parent node<br />

• repeat until a parent is found that need not split<br />

• if the root splits, create a new root which has one key and two pointers.<br />

Characteristics<br />

For a b‐order B+ tree with h levels of index:<br />

• The maximum number of records stored is n = b h<br />

• The minimum number of keys is 2(b / 2)<br />

Prepared By :­<br />

Er. Harvinder Singh<br />

Assist Prof., CSE, H.C.T.M (Kaithal) Page ‐ 221 ‐<br />

h − 1

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

Saved successfully!

Ooh no, something went wrong!