Answers for "adding element to a heap"

1

add element to heap python

import heapq
H = [21,1,45,78,3,5]
# Covert to a heap
heapq.heapify(H)
print(H)
# Add element
heapq.heappush(H,8)
print(H)
Posted by: Guest on June-29-2021

Code answers related to "adding element to a heap"

Python Answers by Framework

Browse Popular Code Answers by Language