My program is in working order and is fully written out: http://pastebin.com/F0q
ID: 3536688 • Letter: M
Question
My program is in working order and is fully written out: http://pastebin.com/F0qAJmP6 The idea of my assignment is to manipulate trees in adding, removing, peeking, etc at these heaps of data, by defining a class named Heap12Tester that extends junit.framework.TestCase and that implements a test plan. And also to define a generic class Heap12> that implements the PQueue interface. The goal is to run two different types of Huffcompress in order to see how much our code can compress. My question is, can anyone think of a more efficient way of writing the add, remove, bubbleUp or trickledown methods? The pre existing code is in the link above!Explanation / Answer
It's not possible to get a more efficient code, in terms of time complexity. Your code takes O(logn) time for each operation, which would be minimum time taken for any heap.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.