Computers and Technology
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.

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 02:00, alexabessin
Aisha has finished working on a word processing document that contains 15 pages. she has added some special elements in the first three pages, page 9 and 10, and page 15 from the document. she wants to print only these pages to see how they look. which option is the correct way to represent (in the print dialog box) the pages that aisha wants to print?
Answers: 3
image
Computers and Technology, 22.06.2019 10:10, joanasprinkman2262
3. bob is arguing that if you use output feedback (ofb) mode twice in a row to encrypt a long message, m, using the same key each time, it will be more secure. explain why bob is wrong, no matter what encryption algorithm he is using for block encryption (15 points).
Answers: 3
image
Computers and Technology, 22.06.2019 23:30, Molly05
In my email i got a message it says a quick message and in message details on who its from its says nicole and under nicole is 50e0bf08e5b671@ualwgypg91wa5wl. uzo9kbud3qjwddygd5.vng -
Answers: 1
image
Computers and Technology, 23.06.2019 05:00, mikeysoulemison
Jason works as an accountant in a department store. he needs to keep a daily record of all the invoices issued by the store. which file naming convention would him the most?
Answers: 2
Do you know the correct answer?
A median priority queue. Given a set of keys, a median key is a key in the "middle" when the keys ar...

Questions in other subjects:

Konu
Arts, 17.10.2021 15:10
Konu
Mathematics, 17.10.2021 15:10
Konu
Mathematics, 17.10.2021 15:10