we are going to look at min heap implementation it shouldn' be difficult to reverse the logic in order to get max heapclass heapdef __init__(self)self heap [ self size we initialize our heap list with zero to represent the dummy first element (remember that we are only doing this to make the math simplerwe also create variable to hold the size of the heap this would not be necessary as suchsince we could check the size of the listbut we would always have to remember to reduce it by one so we chose to keep separate variable instead inserting inserting an item is very simple in itself we add the new element to the end of the list (which we understand to be the bottom of the treethen we increment the size of the heap by one but after each insertwe need to float the new element up if needed bear in mind that the lowest element in the min heap needs to be the root element we first create helper method called float that takes care of this let us look at how it is meant to behave imagine that we have the following heap and want to insert the value the new element has occupied the last slot in the third row or level its index value is now we compare that value with its parent the parent is at index / (integer divisionthat element holds so we swap the