Hi
Implement insert(priority, string_value) that inserts an element in the heap, and delete_max() that removes the value with the highest priority and returns the corresponding string value. (Do not implement delete_min). Since delete_min is not required, optimize the heap structure for delete_max. Write a program that inserts 1,000 random elements in your 5-Heap, and then outputs them from the highest priority value to the lowest using delete_max(). (The heap will be empty at the end of the program.) Output only the result of delete_max(), one element at a time, such as:
681469 "element 1"
529834 "element 2"
...

VulpesPosted Nov 6, 2014, 1:22 PM
This is based on the implementation of the more general d-ary heap of ints here:
http://www.nada.kth.se/kurser/kth/2D1340/inda00/hw0012s.html
though I've specialized it to only implement a 5-heap of Element objects.
As I wasn't keen on some of the method names, I've altered them to be more java-like.
The code seems to be working fine:
SUNIL GUTTAPosted Nov 11, 2014, 10:54 AM
Link to code :- http://ideone.com/kTCXuf#stdin
Thank you My friend