python data structures heap is special tree structure in which each parent node is less than or equal to its child node thenit is called min heap if each parent node is greater than or equal to its child nodethen it is called max heap it is very useful is implementing priority queueswhere the queue item with higher weightage is given more priority in processing detailed discussion on heaps is available in our website here please study it firstif you are new to head data structure in this we will see the implementation of heap data structure using python create heap heap is created by using python' inbuilt library named heapq this library has the relevant functions to carry out various operations on heap data structure belowis list of these functions heapify this function converts regular list to heap in the resulting heap the smallest element gets pushed to the index position but rest of the data elements are not necessarily sorted heappush this function adds an element to the heap without altering the current heap heappop this function returns the smallest data element from the heap heapreplace this function replaces the smallest data element with new value supplied in the function creating heap heap is created by simply using list of elements with the heapify function in the below examplewe supply list of elements and the heapify function rearranges the elements bringing the smallest element to the first position import heapq [ , , , , , use heapify to rearrange the elements heapq heapify(hprint(hwhen the above code is executedit produces the following result[