SlideShare a Scribd company logo
1 of 24
Download to read offline
Section 6.8
Binomial Queues
1
Heap Operations: Merge
2
✤ Given two binary heaps H1 and H2, produce a new heap H’ combining H1 and H2
✤ Binary heaps take !(n1 + n2) time to merge
✤ i.e. they can never merge in better than linear time
✤ We can do better, however
✤ Merge in O(log N) time
✤ this comes at the expensive of a slight performance hit on our other operations
BinomialTrees
3
✤ Binomial trees are recursive defined
✤ Start with one node
✤ This is a binomial tree of height 0
✤ To form a tree of height k, attach two
trees of height k - 1 together
✤ Attach one as a child of the root
of the other
B0 B1 B2
B3
B0 B1 B2
B3
B4
4
B4
BinomialTree Size
5
✤ A binomial tree of height k has 2k
nodes
✤ Conversely, a binomial tree with n
nodes has log2(n) height
✤ The number of nodes at level d of a
tree with height k is the binomial
coefficient:
k
d
!
"
#
$
%
& =
k!
d!(k − d)!
B3
Binomial Queues
6
✤ Binomial Heaps/Binomial Queues
✤ use a forest of binomial trees
✤ use each binomial tree {0,1} times
✤ impose heap ordering on each binomial tree
✤ no relationship between the roots of each tree
Binomial Queues
7
16
18
12
21 24
65
H1:
Binomial Queue Size
✤ A binomial queue H with N nodes has O(log N) binomial trees
✤ let k be the largest integer such that 2k ≤ N
✤ observe that k ≤ log2(N)
✤ N can be written as the sum of unique powers of 2, the largest of which is 2k
✤ this sum uses each power of 2 {0,1} times
✤ the sum has at most k + 1 terms in it
✤ each term corresponds to a binomial tree of 2n nodes in the forest of H
8
Merge
✤ “Add” corresponding trees from the two
forests
✤ For k from 0 to maxheight
✤ If neither queue has a Bk, skip
✤ If only 1, leave it
✤ If two, attach the larger priority root
as a child of the other,
producing a tree of height k + 1
✤ If three, pick two to merge, leave 1
9
16
18
12
21 24
65
H1:
14
26
23
51 24
65
H2:
13
O(log N)!
After Merging H1 and H2
10
12
21 24
65
14
26 16
18
23
51 24
65
13
Insertion
11
✤ To insert a node X into a binomial queue H:
✤ Observe that a single node is a binomial tree of height 0
✤ So treat X as a binomial queue
✤ Merge X and H
✤ Merge operation takes log(N) time
✤ Therefore so does insert
insert(1)
12
1
insert(2)
13
1
2
insert(3)
14
1
2
3
insert(4)
15
1
2 3
4
insert(5)
16
5 1
2 3
4
insert(6)
17
5
6
1
2 3
4
insert(7)
18
5
6
1
2 3
4
7
deleteMin
19
✤ To deleteMin from a binomial queue H
✤ Find the binomial tree with the smallest root, let this be Bk
✤ Remove Bk from H, leaving the rest of the trees to form queue H’
✤ Delete (and return to user) the root of Bk
✤ this leaves us with the children of Bk’s root,
which are binomial trees of size B0, B1, ..., Bk-1
✤ then let the trees B0, B1, ..., Bk-1 form a new binomial queue H’’
✤ Merge H’ and H’’ to repair the tree
Also O(log N)!
deleteMin
20
12
21 24
65
14
26 16
18
23
51 24
65
13
deleteMin
21
12
21 24
65
14
26 16
18
21 24
65
14
26 16
18
H'' :
deleteMin
22
23
51 24
65
H' :
14
65
14
26 16
18
H'' :
21
13
deleteMin
23
13
21 24
65
14
26 16
18
23
51 24
65
Non-Standard Operations
24
✤ percolateUp
✤ identical to binary heap
✤ decreaseKey
✤ percolateUp as far as root of binomial tree
✤ delete (an arbitrary node)
✤ decreaseKey to -∞, then deleteMin

More Related Content

What's hot

Lec 17 heap data structure
Lec 17 heap data structureLec 17 heap data structure
Lec 17 heap data structure
Sajid Marwat
 
B trees in Data Structure
B trees in Data StructureB trees in Data Structure
B trees in Data Structure
Anuj Modi
 
Binomial heap presentation
Binomial heap presentationBinomial heap presentation
Binomial heap presentation
Hafsa.Naseem
 
My lectures circular queue
My lectures circular queueMy lectures circular queue
My lectures circular queue
Senthil Kumar
 
Travelling salesman dynamic programming
Travelling salesman dynamic programmingTravelling salesman dynamic programming
Travelling salesman dynamic programming
maharajdey
 
Graphs In Data Structure
Graphs In Data StructureGraphs In Data Structure
Graphs In Data Structure
Anuj Modi
 

What's hot (20)

Lec 17 heap data structure
Lec 17 heap data structureLec 17 heap data structure
Lec 17 heap data structure
 
Leftist heap
Leftist heapLeftist heap
Leftist heap
 
Red black tree
Red black treeRed black tree
Red black tree
 
B trees in Data Structure
B trees in Data StructureB trees in Data Structure
B trees in Data Structure
 
Data Structure and Algorithms Hashing
Data Structure and Algorithms HashingData Structure and Algorithms Hashing
Data Structure and Algorithms Hashing
 
Binomial heap presentation
Binomial heap presentationBinomial heap presentation
Binomial heap presentation
 
Binomial Heaps
Binomial HeapsBinomial Heaps
Binomial Heaps
 
Abstract Data Types
Abstract Data TypesAbstract Data Types
Abstract Data Types
 
Red black tree
Red black treeRed black tree
Red black tree
 
Heap sort
Heap sortHeap sort
Heap sort
 
My lectures circular queue
My lectures circular queueMy lectures circular queue
My lectures circular queue
 
Heap sort
Heap sortHeap sort
Heap sort
 
b+ tree
b+ treeb+ tree
b+ tree
 
18 hashing
18 hashing18 hashing
18 hashing
 
Travelling salesman dynamic programming
Travelling salesman dynamic programmingTravelling salesman dynamic programming
Travelling salesman dynamic programming
 
Error Detection and correction concepts in Data communication and networks
Error Detection and correction concepts in Data communication and networksError Detection and correction concepts in Data communication and networks
Error Detection and correction concepts in Data communication and networks
 
Linked list
Linked listLinked list
Linked list
 
Polynomial reppresentation using Linkedlist-Application of LL.pptx
Polynomial reppresentation using Linkedlist-Application of LL.pptxPolynomial reppresentation using Linkedlist-Application of LL.pptx
Polynomial reppresentation using Linkedlist-Application of LL.pptx
 
Schedule in DBMS
Schedule in DBMSSchedule in DBMS
Schedule in DBMS
 
Graphs In Data Structure
Graphs In Data StructureGraphs In Data Structure
Graphs In Data Structure
 

Viewers also liked (6)

Binomial heap (a concept of Data Structure)
Binomial heap (a concept of Data Structure)Binomial heap (a concept of Data Structure)
Binomial heap (a concept of Data Structure)
 
binomial & fibonaccci heap by priya
binomial & fibonaccci heap by priyabinomial & fibonaccci heap by priya
binomial & fibonaccci heap by priya
 
Binomial Heap
Binomial HeapBinomial Heap
Binomial Heap
 
Heap tree
Heap treeHeap tree
Heap tree
 
Poscat seminar 4
Poscat seminar 4Poscat seminar 4
Poscat seminar 4
 
Binomial Heaps and Fibonacci Heaps
Binomial Heaps and Fibonacci HeapsBinomial Heaps and Fibonacci Heaps
Binomial Heaps and Fibonacci Heaps
 

Similar to Binomial queues (8)

Applicationof datastructures
Applicationof datastructuresApplicationof datastructures
Applicationof datastructures
 
Applicationof datastructures
Applicationof datastructuresApplicationof datastructures
Applicationof datastructures
 
Applications of datastructures
Applications of datastructuresApplications of datastructures
Applications of datastructures
 
Binomial heaps
Binomial heapsBinomial heaps
Binomial heaps
 
Lecture3
Lecture3Lecture3
Lecture3
 
Rand final
Rand finalRand final
Rand final
 
358 33 powerpoint-slides_12-heaps_chapter-12
358 33 powerpoint-slides_12-heaps_chapter-12358 33 powerpoint-slides_12-heaps_chapter-12
358 33 powerpoint-slides_12-heaps_chapter-12
 
Heaps 4up
Heaps 4upHeaps 4up
Heaps 4up
 

Recently uploaded

Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
amitlee9823
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 

Recently uploaded (20)

Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
22-prompt engineering noted slide shown.pdf
22-prompt engineering noted slide shown.pdf22-prompt engineering noted slide shown.pdf
22-prompt engineering noted slide shown.pdf
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 

Binomial queues