Binomial Heap Union and Insertion Operations

preview_player
Показать описание
#techlearners
The procedure of uniting two binomial heaps into one binomial heap
Algorithm: given binomial heaps H1 and H2
Step 1. Merge H1 and H2, i.e. link the roots of H1 and H2 in non-decreasing order.
Step 2. Restoring binomial heap by linking binomial trees of the same degree together: traverse the linked list, keep track of three pointers, Previous, current and next.
Case 1: degrees of current and next are not same, move ahead.
Case 2: If degree of next of next is also same, move ahead.
Case 3: If key of current is smaller than or equal to key of next, make next as a child of current by linking it with current.
Case 4: If key of current is greater than next, then make current as child of next.
Time Complexity of Union Operation O(logn)

The procedure to insert a key in binomial heap
Step 1. create a new binomial heap H1 of one node of value x
Step 2. Unite H1 and H.
Insert Binomial Heap()
1: SET H’ = Create Binomial-Heap()
2: SET Parent[x] = NULL,
Child[x] = NULL and
Sibling[x] = NULL,
Degree[x] = NULL
3: SET Head[H’] = x
4: SET Head[H] = Union Binomial Heap(H, H’)
5: END
Time Complexity of insert operation– O(logn)

TECHLEARNERS BY NEERAJ SAXENA
Рекомендации по теме
Комментарии
Автор

Great video! One of the only resources on Youtube to understand binary heap in depth along with time complexity analysis. Thank you!

theawless
Автор

Plz keep posting more videos sir
You have great skill to explain these topics..
Thanks..

Ayushkumar-nhid
Автор

New subscriber 😀😀the explanation is really detailed and really helpful, thank you sooo much sir

whippedforbangtanftjin
Автор

Hi thanks for the video it helped me, but I think you made a mistake in the insert example when you inserted 8, when linking the two binomial trees the one with 2 as root must be on the leftmost child of the one that has 1 as root not like you did, you put it on the rightmost child!

anistertaki_
Автор

that same quesyion of insertion came in my exam with 8 marks. exempting the insert 5 part

masukmarufahmed
Автор

hindi me bolte to vedio aur acchi lagti

AnkitPandey-ktxz