{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lecture17-Heaps

# lecture17-Heaps - 50 48 31 17 44 10 6 37 3 18 29 Binomial...

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

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

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

View Full Document
2 Binomial Tree Binomial tree. Recursive definition: B k-1 B k-1 B 0 B k B 0 B 1 B 2 B 3 B 4
3 Binomial Tree Useful properties of order k binomial tree B k . Number of nodes = 2 k . Height = k. Degree of root = k. Deleting root yields binomial trees B k-1 , … , B 0 . Proof. By induction on k. B 0 B 1 B 2 B 3 B 4 B 1 B k B k+1 B 2 B 0

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

View Full Document
4
5 Binomial Tree A property useful for naming the data structure. B k has nodes at depth i. B 4 i k 6 2 4 = depth 2 depth 3 depth 4 depth 0 depth 1

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

View Full Document
6
7 Binomial Heap Binomial heap. Vuillemin, 1978. Sequence of binomial trees that satisfy binomial heap property. each tree is min-heap ordered 0 or 1 binomial tree of order k 55 45 32 30 24 23 22 50 48 31 17 44 8 29 10 6 37 3 18

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

View Full Document
8 Binomial Heap: Implementation Implementation. Represent trees using left-child, right sibling pointers. three links per node (parent, left, right) Roots of trees connected with singly linked list. degrees of trees strictly decreasing from left to right

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: 50 48 31 17 44 10 6 37 3 18 29 Binomial Heap 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 9 10 Binomial Heap: Properties Properties of N-node binomial heap. ■ Min key contained in root of B , B 1 , . . . , B k . ■ Contains binomial tree B i iff b i = 1 where b n ⋅ b 2 b 1 b 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 11 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'...
View Full Document

{[ snackBarMessage ]}