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

Deletion<br />

In the previous section, we saw that the SIZE and DEPTH properties of (2,4)‐<br />

trees can be maintained efficiently as new items are inserted into the tree. We<br />

now show that the same result holds as items are removed.<br />

The deletion algorithm<br />

Once again we'll begin with a basic algorithm that we'll adjust. We want to<br />

DELETE a key k from T. For now, we shall assume that k is stored in a node v<br />

whose children are all external nodes. Here are the steps we follow:<br />

perform a SEARCH for k in T,<br />

if it fails then we don't need to DELETE the item so we exit,<br />

otherwise (if it succeds) then we find k in a node v with only external<br />

children (by our assumption).<br />

now we simply remove k from v and delete the external node child to the left of<br />

k<br />

B‐Tree<br />

A B‐tree is a tree data structure that keeps data sorted and allows searches,<br />

insertions, deletions, and sequential access in logarithmic amortized time. The<br />

B‐tree is a generalization of a binary search tree in that more than two paths<br />

diverge from a single node. [1] Unlike self‐balancing binary search trees, the B‐<br />

tree is optimized for systems that read and write large blocks of data. It is most<br />

commonly used in databases and filesystems.<br />

Overview<br />

In B‐trees, internal (non‐leaf) nodes can have a variable number of child nodes<br />

within some pre‐defined range. When data is inserted or removed from a node,<br />

its number of child nodes changes. In order to maintain the pre‐defined range,<br />

Prepared By :­<br />

Er. Harvinder Singh<br />

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

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

Saved successfully!

Ooh no, something went wrong!