lecture17-Heaps

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

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

View Full Document Right Arrow Icon
Binomial Heaps These lecture slides are adopted from CLRS, Chapters 6, 19. Source: internet Lecture 17
Background image of page 1

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

View Full DocumentRight Arrow Icon
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
Background image of page 2
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
Background image of page 3

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

View Full DocumentRight Arrow Icon
4
Background image of page 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
Background image of page 5

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

View Full DocumentRight Arrow Icon
6
Background image of page 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
Background image of page 7

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

View Full DocumentRight Arrow Icon
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
Background image of page 8
Background image of page 9

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

View Full DocumentRight Arrow Icon
Background image of page 10
Background image of page 11
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

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 / 11

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

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online