subject
Computers and Technology, 04.03.2020 23:37 Hfruit

A median priority queue. Given a set of keys, a median key is a key in the "middle" when the keys are sorted. When the number of keys is odd, the middle key is unique. However, when the number of keys is even, there are two middle keys. We call on the lower median key and the other the upper median key. For example, if the keys are {3, 8, 2, 10,5,9), then the lower median key is 5 while the upper median key is 8.
For this problem, we wish to implement the MedianPQADT that supports the following methods in O(logn) time:
Insert Item(k, e), RemoveLower Median(), Remove UpperMedian().
When n is even, the items to return for RemoveLowerMedian() and RemoveUpper Me dian() are obvious. When n is odd, let these methods simply return the item with the median key.
Our implementation involves two heaps -a max-heap H, and a min-heap Hr. It always maintains the property that contains the [n/2 smallest keys and HR contains the [n/2] largest keys.
(a1) Assume your current set of items are stored using the two-heap im- plementation with the said property. Write a pseudocode for the three methods Insertitem(k, e), RemoveLowerMedian(), Remove Upper Median().
(a2) Briefly argue why the running times of your pseudocodes for the three methods is O(logn).
(b) Starting with an empty two-heap, do six Insertitem with keys 6, 5, 4, 3, 2, 1. Draw what the heaps look like at the end of each insertion step. Then apply RemoveLower Median() and draw the tree at the end of this step.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 06:30
Exchanging which type of data uses the least bandwidth? music photographs video voice bandwidth- the amount of data that can be moved between two points in a set time period
Answers: 1
question
Computers and Technology, 22.06.2019 22:30
What is the most popular genre of video games?
Answers: 1
question
Computers and Technology, 23.06.2019 02:00
For a typical middle-income family, what is the estimated cost of raising a child to the age of 18? $145,500 $245,340 $304,340 $455,500
Answers: 1
question
Computers and Technology, 23.06.2019 09:00
Before you record your own voice, you should a. record other people's voices b. warm up and practice difficult names c. listen to your favorite songs d. read a transcript of a good radio news segment
Answers: 1
You know the right answer?
A median priority queue. Given a set of keys, a median key is a key in the "middle" when the keys ar...
Questions
question
Mathematics, 25.05.2021 23:00
question
Spanish, 25.05.2021 23:00
question
Mathematics, 25.05.2021 23:00
question
Mathematics, 25.05.2021 23:00
question
Mathematics, 25.05.2021 23:00
Questions on the website: 13722362