SlideShare uma empresa Scribd logo
1 de 24
Baixar para ler 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

Mais conteúdo relacionado

Mais procurados

Terminology of tree
Terminology of treeTerminology of tree
Terminology of treeRacksaviR
 
BINARY TREE REPRESENTATION.ppt
BINARY TREE REPRESENTATION.pptBINARY TREE REPRESENTATION.ppt
BINARY TREE REPRESENTATION.pptSeethaDinesh
 
Lec 17 heap data structure
Lec 17 heap data structureLec 17 heap data structure
Lec 17 heap data structureSajid Marwat
 
Binomial heap presentation
Binomial heap presentationBinomial heap presentation
Binomial heap presentationHafsa.Naseem
 
Push Down Automata (PDA) | TOC (Theory of Computation) | NPDA | DPDA
Push Down Automata (PDA) | TOC  (Theory of Computation) | NPDA | DPDAPush Down Automata (PDA) | TOC  (Theory of Computation) | NPDA | DPDA
Push Down Automata (PDA) | TOC (Theory of Computation) | NPDA | DPDAAshish Duggal
 
Stack data structure
Stack data structureStack data structure
Stack data structureTech_MX
 
Hashing Technique In Data Structures
Hashing Technique In Data StructuresHashing Technique In Data Structures
Hashing Technique In Data StructuresSHAKOOR AB
 
B trees in Data Structure
B trees in Data StructureB trees in Data Structure
B trees in Data StructureAnuj Modi
 
Threaded Binary Tree
Threaded Binary TreeThreaded Binary Tree
Threaded Binary Treekhabbab_h
 
1.8 splay tree
1.8 splay tree 1.8 splay tree
1.8 splay tree Krish_ver2
 
Topological Sorting
Topological SortingTopological Sorting
Topological SortingShahDhruv21
 
Binary Heap Tree, Data Structure
Binary Heap Tree, Data Structure Binary Heap Tree, Data Structure
Binary Heap Tree, Data Structure Anand Ingle
 
Trees (data structure)
Trees (data structure)Trees (data structure)
Trees (data structure)Trupti Agrawal
 
queue & its applications
queue & its applicationsqueue & its applications
queue & its applicationssomendra kumar
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Treesagar yadav
 
Signed Addition And Subtraction
Signed Addition And SubtractionSigned Addition And Subtraction
Signed Addition And SubtractionKeyur Vadodariya
 

Mais procurados (20)

Terminology of tree
Terminology of treeTerminology of tree
Terminology of tree
 
BINARY TREE REPRESENTATION.ppt
BINARY TREE REPRESENTATION.pptBINARY TREE REPRESENTATION.ppt
BINARY TREE REPRESENTATION.ppt
 
Lec 17 heap data structure
Lec 17 heap data structureLec 17 heap data structure
Lec 17 heap data structure
 
Binomial heap presentation
Binomial heap presentationBinomial heap presentation
Binomial heap presentation
 
Push Down Automata (PDA) | TOC (Theory of Computation) | NPDA | DPDA
Push Down Automata (PDA) | TOC  (Theory of Computation) | NPDA | DPDAPush Down Automata (PDA) | TOC  (Theory of Computation) | NPDA | DPDA
Push Down Automata (PDA) | TOC (Theory of Computation) | NPDA | DPDA
 
Stack data structure
Stack data structureStack data structure
Stack data structure
 
Binary search trees
Binary search treesBinary search trees
Binary search trees
 
Digital Search Tree
Digital Search TreeDigital Search Tree
Digital Search Tree
 
Binary search tree(bst)
Binary search tree(bst)Binary search tree(bst)
Binary search tree(bst)
 
Hashing Technique In Data Structures
Hashing Technique In Data StructuresHashing Technique In Data Structures
Hashing Technique In Data Structures
 
B trees in Data Structure
B trees in Data StructureB trees in Data Structure
B trees in Data Structure
 
Threaded Binary Tree
Threaded Binary TreeThreaded Binary Tree
Threaded Binary Tree
 
1.8 splay tree
1.8 splay tree 1.8 splay tree
1.8 splay tree
 
Topological Sorting
Topological SortingTopological Sorting
Topological Sorting
 
Binary Heap Tree, Data Structure
Binary Heap Tree, Data Structure Binary Heap Tree, Data Structure
Binary Heap Tree, Data Structure
 
Trees (data structure)
Trees (data structure)Trees (data structure)
Trees (data structure)
 
queue & its applications
queue & its applicationsqueue & its applications
queue & its applications
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
Signed Addition And Subtraction
Signed Addition And SubtractionSigned Addition And Subtraction
Signed Addition And Subtraction
 
Tree - Data Structure
Tree - Data StructureTree - Data Structure
Tree - Data Structure
 

Destaque

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)Saliha Bilal
 
binomial & fibonaccci heap by priya
binomial & fibonaccci heap by priyabinomial & fibonaccci heap by priya
binomial & fibonaccci heap by priyaShohani Priya
 
Binomial Heap
Binomial HeapBinomial Heap
Binomial HeapGoa App
 
Binomial Heaps and Fibonacci Heaps
Binomial Heaps and Fibonacci HeapsBinomial Heaps and Fibonacci Heaps
Binomial Heaps and Fibonacci HeapsAmrinder Arora
 

Destaque (7)

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
 
Heaps
HeapsHeaps
Heaps
 
Binomial Heaps and Fibonacci Heaps
Binomial Heaps and Fibonacci HeapsBinomial Heaps and Fibonacci Heaps
Binomial Heaps and Fibonacci Heaps
 

Semelhante a Binomial Queues: Efficient Heap Operations in O(log N) Time

Semelhante a Binomial Queues: Efficient Heap Operations in O(log N) Time (9)

Binomial Heaps
Binomial HeapsBinomial Heaps
Binomial Heaps
 
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
 

Último

College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesPrabhanshu Chaturvedi
 
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 Bookingdharasingh5698
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 

Último (20)

College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 
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
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 

Binomial Queues: Efficient Heap Operations in O(log N) Time