Heaps and priority queues

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/17

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 7:08 PM on 4/30/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

18 Terms

1
New cards

What is the worst-case time for Heapsort to sort an array of n records that each have unique key values?

Θ(nlogn)

2
New cards

Heapsort (as the code is written in this module) is a stable sorting algorithm. Recall that a stable sorting algorithm maintains the relative order of records with equal keys.

false

3
New cards

(Assuming no duplicate key values:) The order of the input records has what impact on the number of comparisons required by Heapsort (as presented in this module)?

There is a constant factor difference

4
New cards

What is the running time of Heapsort when the input is an array where all key values are equal?

Θ(n)

5
New cards

In which cases are the time complexities the same for Heapsort?

Worst and Average

6
New cards

A disadvantage of Heapsort is:

it is not stable (repeated values won’t stay in same order as before)

7
New cards

How much auxilliary space or overhead (beyond the array holding the records) is needed by Heapsort?

Θ(1)

8
New cards

heap is a..? (data structure or abstract data type)

data structure

9
New cards

Priority queue is a..? (data structure or abstract data type)

abstract data type

10
New cards

The tree corresponding to a heap is required to be a complete tree. (true of false)

true

11
New cards

what is max heap?

the value stored at a node is less than or equal to the root (greatest value)

12
New cards

what is a min heap?

the internal value are greater than or equals to the root (smallest value)

13
New cards

height of a complete tree?

h = log n

14
New cards

Peek operation running time for heaps

Θ(1)

15
New cards

worst case running time for insertion and removes for heaps

O(log n)

16
New cards

explain the removal from a min heap

The remove() function will remove the root (smallest number). You replace the root with the last leaf in the tree. Then you percolate the number down if the number is greater than the childrens then you swap with the smallest number until the tree is heapified.

17
New cards

explain the removal from a max heap

the removal() function will remove the root(largest number). You replace the previous root with the last leaf in the tree. if the now root is less than or equal to the children than you swap with the largest number until the tree is heapified.

18
New cards

Build heaps takes? (time complexity) in the worst case.

Θ(n)