lecture18-Heaps

# lecture18-Heaps - 45 32 30 24 23 22 50 48 31 17 44 8 29 10...

This preview shows pages 1–12. Sign up to view the full content.

Binomial Heaps These lecture slides are adopted from CLRS, Chapters 6, 19. Source: internet Lecture 18

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Representing Binomial Heaps parent key degree child sibling Each node is represented by a structure like this 10 25 18 12 1 27 17 38 11 29 14 8 6 2
3 Binomial Heap: Properties Properties of N-node binomial heap. Min key contained in root of B 0 , B 1 , . . . , B k . Contains binomial tree B i iff b i = 1 where b n b 2 b 1 b 0 is binary representation of N. At most log 2 N + 1 binomial trees. Height log 2 N . 55 45 32 30 24 23 22 50 48 31 17 44 8 29 10 6 37 3 18 N = 19 # trees = 3 height = 4 binary = 10011

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
4 Binomial Heap: Union Create heap H that is union of heaps H' and H''. "Mergeable heaps." Easy if H' and H'' are each order k binomial trees. connect roots of H' and H'' choose smaller key to be root of H H'' 55 45 32 30 24 23 22 50 48 31 17 44 8 29 10 6 H'
5 Binomial Heap: Union 0 0 1 1 1 0 0 1 + 0 1 1 1 1 1 1 1 0 1 19 + 7 = 26 55 45 32 30 24 23 22 50 48 31 17 44 8 29 10 6 37 3 18 41 33 28 15 25 7 12 +

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
6 Binomial Heap: Union 55 45 32 30 24 23 22 50 48 31 17 44 8 29 10 6 37 3 18 41 33 28 15 25 7 12 +
7 Binomial Heap: Union 55 45 32 30 24 23 22 50 48 31 17 44 8 29 10 6 37 3 41 33 28 15 25 7 + 12 18 18 12

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
8 55

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 45 32 30 24 23 22 50 48 31 17 44 8 29 10 6 37 3 41 33 28 15 25 7 + 12 18 25 37 7 3 18 12 18 12 9 55 45 32 30 24 23 22 50 48 31 17 44 8 29 10 6 37 3 41 33 28 15 25 7 12 + 18 25 37 7 3 41 28 33 25 37 15 7 3 18 12 18 12 10 55 45 32 30 24 23 22 50 48 31 17 44 8 29 10 6 37 3 41 33 28 15 25 7 + 18 12 41 28 33 25 37 15 7 3 12 18 25 37 7 3 41 28 33 25 37 15 7 3 18 12 11 55 45 32 30 24 23 22 50 48 31 17 44 8 29 10 6 37 3 41 33 28 15 25 7 + 18 12 41 28 33 25 37 15 7 3 12 18 25 37 7 3 41 28 33 25 37 15 7 3 55 45 32 30 24 23 22 50 48 31 17 44 8 29 10 6 18 12 12 Binomial Heap: Union Create heap H that is union of heaps H' and H''. ■ Analogous to binary addition. Running time. O(log N) ■ Proportional to number of trees in root lists ≤ 2( log 2 N + 1). 1 1 1 1 + 1 1 1 1 1 1 1 1 19 + 7 = 26...
View Full Document

## This note was uploaded on 03/30/2011 for the course CS 6713 taught by Professor Su during the Spring '11 term at Arkansas State.

### Page1 / 12

lecture18-Heaps - 45 32 30 24 23 22 50 48 31 17 44 8 29 10...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online