7, 9, 1, 3]#using heapify to convert list into heapheapq.heapify(li)#printing created heapprint("The created heap is :",end="")print(list(li))#using heappush() to push elements into heap#pushes 4heapq.heappush(
We have to use the heapq.heapify() module to create the heapq data structure in a sorted order. Then we use the heapreplace() method to replace an element with a new one. Here we have to pass two parameters, the first one denotes the heapq object where new element will get inserted....