TREAPS
treaps= trees + heaps
INRODUCTION
1. every node in treap data structure has two main entities first is key which is component for tree property and second is priority which components for min heap property.
2. if node1 has higher property than node2 then node2 will lie below the node 1 & if key of node1 is less than key of node2 then node1 will lie in left side of tree and node2 will lie on right side of tree.
OPERATIONS
1. Search => time for successfull search is proportional to depth of node & time of unsuccessfull search is proportional to depth of node.
2. Insertion=> First we will do normal search tree insertion, then after that to make it min heap we will rotate the nodes such that priority of that node is higher than its parent, and rotate it such a way that its depth decreases by one and depth of parent increases byone.
3. Delete=> rotate the node to be deleted with low priority node until the node to be deleted is leaf node,and chop it after it becomes leaf node.
Comments
Post a Comment