07-heapsort

# 07-heapsort - CS 4102 Algorithms Heapsort Expectations...

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

CS 4102, Algorithms: Heapsort • Expectations: • Section 3.5 and CS216 slides • Next: Sections 4.2-4.5 • Graph searching • Problems to do are coming…

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

View Full Document
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
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

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

View Full Document
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
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.

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.

{[ snackBarMessage ]}

### Page1 / 14

07-heapsort - CS 4102 Algorithms Heapsort Expectations...

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

View Full Document
Ask a homework question - tutors are online