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 01:30
Imagine that you have a friend who is starting a small business and is interested in using social media to spread the word. he is not certain that it is a good move, and has come to you for . would you advise him to use social media to advertise his business? why or why not? support you answer with information from the text.
Answers: 1
question
Computers and Technology, 22.06.2019 18:00
When is it appropriate to use an absolute reference
Answers: 1
question
Computers and Technology, 22.06.2019 21:40
Develop a function to create a document in the mongodb database “city” in the collection “inspections.” be sure it can handle error conditions gracefully. a. input -> argument to function will be set of key/value pairs in the data type acceptable to the mongodb driver insert api call b. return -> true if successful insert else false (require a screenshot)
Answers: 2
question
Computers and Technology, 23.06.2019 15:00
Jake really works well with numbers and is skilled with computers but doesn't work well with others. which of the jobs discussed in this unit might be best for jake? why?
Answers: 3
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