Pairing Heaps
CS 261 Oregon State University
Pairing Heaps CS 261 Oregon State University Heaps Heap is a - - PowerPoint PPT Presentation
Pairing Heaps CS 261 Oregon State University Heaps Heap is a great data structure Any chance to make it even better? Seeking an O(1) addition How do we obtain O(1) addition? Answer: only change the location of the root How to
CS 261 Oregon State University
Instead of: Maintain
2 List of subheaps Root 3
9 12 14 10 16 11 5 7 8
2 List of subheaps 6 Insert 2 Root Root List of subheaps 3
9 12 14 10 16 11 5 7 8
3
9 12 14 10 16 11 5 7 8
6
2 List of subheaps 1 Insert List of subheaps Root Root 1 2 3
9 12 14 10 16 11 5 7 8
3
9 12 14 10 16 11 5 7 8
2 List of subheaps 6
17 10 13 15 9
List of subheaps
Merge
2
17 10 13 15 9
6
Subheap pointer
3
9 12 14 10 16 11 5 7 8
3
9 12 14 10 16 11 5 7 8
2
17 10 13 15 9
6 3
9 12 14 10 16 11 5 7 8
17 10 13 15 9
6 3
9 12 14 10 16 11 5 7 8
17 10 13 15 9
6 3
9 12 14 10 16 11 5 7 8
17 10 13 15 9
6 3
9 12 14 10 16 11 5 7 8
17 10 13 15 9
6 3
9 12 14 10 16 11 5 7 8
17 10 13 15 9
6 3
9 12 14 10 16 11 5 7 8
subsequent ones faster