Advanced Programming, Jan-Apr 2015 Assignment 5 30 March, 2015 Due 6 April, 2015 ---------------------------------------------------------------------- NOTE: The usual rules apply about file names for submitting your assignment. ---------------------------------------------------------------------- Filename: heapclass.py Write a Python class that implements min-heaps. The class should be called Heap. An object h of type Heap should support the following operations: h.deletemin() : deletes and returns the minimum element from the heap and updates the heap accordingly This function should raise an IndexError exception with a suitable message if the heap is empty. h.insertheap(val) : inserts val into the heap h h.heapsize() : returns the number of elements in the heap str(h) : returns a suitable string describing contents of h When creating a heap, the default should be to create an empty heap. However, it should also be possible to supply an initial list of values to be put into the heap. For example: h1 = Heap() # Creates an empty heap h2 = Heap([1,11,2,31]) # Creates a heap containing {1,11,2,31} Note that the user supplies the initial values as a list, in arbitrary order. The class definition should ensure that these values are organised as a min-heap. Use the bottom up O(n) heapification algorithm. ======================================================================