Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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)
Source by www.tutorialspoint.com #
 
PREVIOUS NEXT
Tagged: #add #element #heap #python
ADD COMMENT
Topic
Name
1+3 =