CS2420: Lecture 21 - PowerPoint PPT Presentation

1 / 9
About This Presentation
Title:

CS2420: Lecture 21

Description:

Binary Heaps as Priority Queues (Chapter 6) Notational Convention ... Building a Heap. Building a Heap: Asymptotic Analysis. BuildHeap: Asymptotic Analysis ... – PowerPoint PPT presentation

Number of Views:23
Avg rating:3.0/5.0
Slides: 10
Provided by: Vladimir120
Category:
Tags: cs2420 | heaps | lecture

less

Transcript and Presenter's Notes

Title: CS2420: Lecture 21


1
CS2420 Lecture 21
  • Vladimir Kulyukin
  • Computer Science Department
  • Utah State University

2
Outline
  • HeapSort (Chapter 7)
  • Binary Heaps as Priority Queues (Chapter 6)

3
Notational Convention
  • If A is an array that represents a binary heap,
    let mHeapSize be a variable that represents the
    current size of the heap, i.e., the number of
    elements in the array.
  • If we wanted to implement a class called
    CBinaryHeap, we may have that class contain 2
    member variables mHeapSize and mArray, the
    second being an array of templatized elements.

4
Building a Heap
5
Building a Heap Asymptotic Analysis
6
BuildHeap Asymptotic Analysis
7
BuildHeap Asymptotic Analysis
8
HeapSort
9
HeapSort Asymptotic Analysis
  • BuildHeap O(N).
  • The For-Loop executes N times where N is the
    length of the array A.
  • Swap O(1).
  • Decrementing HeapSize O(1).
  • RestoreHeap O(logN).
  • Conclusion HeapSort O(NlogN).
Write a Comment
User Comments (0)
About PowerShow.com