CS 310 Unit 4 Heapsort - CS 310 Unit 4 Heapsort Furman...

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

View Full Document Right Arrow Icon
CS 310 Unit 4 Heapsort Furman Haddix Ph.D. Assistant Professor Minnesota State University,  Mankato
Background image of page 1

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

View Full DocumentRight Arrow Icon
CS 310 Unit 4 Heapsort  Objectives Standard Tree Definitions Introduction to Heapsort O(n log n), like merge sort Sorts in place, like insertion sort Heaps Definition Implementation Heapsort Implementation Priority Queues Priority Queue Implementation Text, Chapter 6
Background image of page 2
Standard Tree Definitions full ternary tree
Background image of page 3

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

View Full DocumentRight Arrow Icon
Standard Tree Terminology Parents Children Left Children Right Children Root Leaf Branch,  Interior branch Descendants Ancestors
Background image of page 4
Full Tree Definitions Full binary tree A binary node is full if it has either 0 or 2 children. A binary tree is full if every node in the tree is full. Full k-ary tree A k-ary node is full if it has either 0 or k children. A k-ary tree is full if every node in the tree is full.
Background image of page 5

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

View Full DocumentRight Arrow Icon
Perfect Tree Definitions Perfect binary tree An n-level binary tree is perfect if it has 2 n -1 nodes. A binary tree is perfect if it is full and all leaves are at  the same level. A perfect binary tree is both full and complete,  although a full and complete tree is not necessarily  perfect. Perfect k-ary tree An n-level k-ary tree is perfect if if has (k n -1)/(k-1)  nodes. A k-ary tree is perfect if it is full and all leaves are at  the same level. A perfect k-ary tree is both full and complete,  although a full and complete tree is not necessarily 
Background image of page 6
Complete Tree Definitions Complete binary tree An n-level tree is complete  if it is perfect through n-1 levels  if every left child has a number of descendants  greater than or equal to the number of descendants  of its right sibling, and  if there is no more than one node that is not full. Complete k-ary tree An n-level tree is complete  if it is perfect through n-1 levels  if every sibling has a number of descendants greater  than or equal to the number of descendants of any  sibling to its right, and  if there is no more than one node that is not full.
Background image of page 7

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

View Full DocumentRight Arrow Icon
Tree A Full? Complete? Perfect? Tree B Full? Complete? Perfect? Tree C Full? Complete? Perfect? Tree D Full? Complete? Perfect? Tree E Full? Complete? Perfect? Tree F Full? Complete? Perfect?
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/09/2008 for the course CS 310 taught by Professor Furmanhaddix during the Spring '08 term at Minnesota State University, Mankato.

Page1 / 36

CS 310 Unit 4 Heapsort - CS 310 Unit 4 Heapsort Furman...

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

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