07-heapsort.ppt

07-heapsort.ppt - CS 4102, Algorithms: Heapsort...

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

View Full Document Right Arrow Icon
CS 4102, Algorithms: Heapsort • Expectations: • Section 3.5 and CS216 slides • Next: Sections 4.2-4.5 • Graph searching • Problems to do are coming…
Background image of page 1

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

View Full DocumentRight Arrow Icon
Review from CS216 • Review these slides! • Slides from 3-26-03 on Priority Queues (Binary Min Heaps) http://www.cs.virginia.edu/~cs216/notes/slides/heaps.pdf
Background image of page 2
Reminders, Terminology • ADT priority queue • What’s an ADT? • What’s high priority? • Operations? • How is data stored? • Heap data structure • The heap structure : an almost-complete binary tree • The heap condition or heap order property: • At any given node j, value[j] has higher priority than either of its child nodes’ values • Heaps are weakly sorted • Higher priority: large or small? • Max-heap vs min-heap
Background image of page 3

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

View Full DocumentRight Arrow Icon
Storing Heaps in Lists • Heap structure allows us to store heaps in lists (arrays, vectors) effectively • Indexing in our text: v[1] is the root. v[n] is the last item • parent of node j is at j/2 • left-child of node j is at: • 2*j • right-child of node j is at: • 2*j + 1 • “first leaf” is • n/2 + 1
Background image of page 4
Basic Heap Algorithms • Let’s work with max-heaps for know • Define a set of simple heap operations • Traverse tree, thus logarithmic complexity • Highest item? • At the root.
Background image of page 5

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

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 14

07-heapsort.ppt - CS 4102, Algorithms: Heapsort...

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

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