lecture16-Heaps

lecture16-Heaps - Binary and Binomial Heaps Lecture 16...

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

View Full Document Right Arrow Icon
Binary and Binomial Heaps These lecture slides are adopted from CLRS, Chapters 6, 19. Source: internet Lecture 16
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 Binary Heap: Definition Binary heap. Almost complete binary tree. filled on all levels, except last, where filled from left to right Min-heap ordered. every child greater than (or equal to) parent 06 14 78 18 81 77 91 45 53 47 64 84 99 83
Background image of page 2
3 Binary Heap: Properties Properties. Min element is in root. Heap with N elements has height = log 2 N . 06 14 78 18 81 77 91 45 53 47 64 84 99 83 N = 14 Height = 3
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 Binary Heaps: Array Implementation Implementing binary heaps. Use an array: no need for explicit parent or child pointers. Parent(i) = i/2 Left(i) = 2i Right(i) = 2i + 1 06 14 78 18 81 77 91 45 53 47 64 84 99 83 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Background image of page 4
5 Binary Heap: Insertion Insert element x into heap. 06 14 78 18 81 77 91 45 53 47 64 84 99 83 42 next free slot
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 Binary Heap: Insertion Insert element x into heap. 06 14 78 18 81 77 91 45 53 47 64 84 99 83 42 swap with parent
Background image of page 6
7 Binary Heap: Insertion Insert element x into heap.
Background image of page 7

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

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the 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 / 19

lecture16-Heaps - Binary and Binomial Heaps Lecture 16...

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

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