Professional Documents
Culture Documents
DS Unit Iii
DS Unit Iii
Department Of CSE
SRM University-AP
14 décembre 2023
struct Node
{
struct Node *left ;
unsigned short lThreadFlag ; //1 : denotes the left pointer
pointing the predecessor, 0 : denotes the left pointer pointing the left chaild.
int data ;
unsigned short rThreadFlag ; //1 : denotes the right pointer
pointing the successor, 0 : denotes the right pointer pointing the right chaild.
struct Node *right ;
};
In left-right rotation, the arrangements are first shifted to the left and then
to the right.
1. Do left rotation on x − y.
2. Do right rotation on y − z
In right-left rotation, the arrangements are first shifted to the right and then
to the left.
1. Do right rotation on x − y.
2. Do left rotation on z − y
» There are two differences between the B-tree and the B+ tree :
1 Each data entry must be represented at the leaf level, even
though there may be internal nodes with the same keys.
Because the internal nodes are used only for searching,
they generally do not contain data.
2 Each leaf node has one additional pointer, which is used to
move to the next leaf node in sequence.
2. Insert 15.
3. Insert 25.
4. Insert 35.
5. Insert 45
* Search the key to be deleted. If search key is there then follow the
following steps.
CI : The key to be deleted is present only at the leaf node not in the
internal nodes. Then
CI-1. If that node has more than minimum keys, then simple delete it.
CI-2. If that node has exact minimum keys, then delete the key and
borrow a key from the immediate sibling. Then update its parent
with it inorder successor.
CI-3. If the node and sibling nodes also have minimum keys then
merge with any one of its sibling.
CII :
CIII :
CI-2. If that node has exact minimum keys, then delete the key and borrow
a key from the immediate sibling. Then consider a proper element as
its parent. Delete 5.
CII-2. If node has minimum keys, then delete the key and borrow a key from
its immediate sibling (through the parent). Fill the empty space
created in internal node with appropriate key. Delete 35.
CII-3. This case is similar to CII-1 but here, empty space is generated above
the immediate parent node. After deleting the key, merge the empty
space with its sibling. Fill the empty space in the grandparent node
with the inorder successor. Delete 25.
CIII : In this case, the height of the tree gets reduced. It is a little
complicated. It can be understood in the illustrations below. Delete 55.