Professional Documents
Culture Documents
Unit No:3
Unit Name: Advanced Data Structures
Faculty Name : Ms Vanita Mane
Harsha Saxena
Siddhi Kadu.
Module No 3: Advanced Data Structures
Lecture No:19
Union operation on Binomial
Heap
Uniting two binomial heaps
• H <- Binomial-Heap-Merge(H1,H2)
• This merges the root lists of H1 and H2 in increasing order of
root degree
• Walk across the merged root list, merging binomial trees of equal
degree. If there are three such trees in a row only merge the last two
together(to maintain property of increasing order of root degree as
we walk the roots)
32 63
58 19
93
53
69
H
60 80 2 18
32 63
58 19
93
53
69
X next-X Sibling[next-x]
H
60 80 2 18
Prev-X=nil
32 63 58 19
93
53
69
32 63 58 19
93
53
69
Move forward
Case 3
Case 4
Degree[x]=Degree[next-x]=Degree[sibling[next-x]] Move x
X is parent
Degree[x]=Degree[next-x] and key[x]≤key[next-x]
Prev-x=Nill x Next-X
H
60 80 2 18
32 63
58 19
93
Degree[x] ≠ Degree[Next-X]
53
apply Case 1 move forward
69
Prev-x x Next-X
H
60 80 2 18
32 63
58 19
93
Degree[x] ≠ Degree[Next-X]
53
apply Case 1 move forward
69
Prev-x x Next-X
H
60 80 2 18
32 63
58 19
93
53
69
Degree[x]= Degree[next-x] and sibling[next-x]=nill
Key[x]≤key[next-x]
apply Case 3 make next-x the leftmost child of x
18 32 63
93
58 19 53
H1 H2
x next-x Sibling[next-x]
H
Prev-x=nill
Sibling[next-x]
x next-x
H
Prev-x=nill
next-x Sibling[next-x]
Prev-x x
H