Create heapify.py

This commit is contained in:
marina 2023-08-02 12:59:18 -07:00 committed by GitHub
parent cf0a3cd358
commit e8882c2da0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

11
heaps/heapify.py Normal file
View File

@ -0,0 +1,11 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# author: bt3gl
import heapq
min_heap = [3,1,2]
heapq.heapify(min_heap)
max_heap = [-x for x in min_heap]
heapq.heapify(max_heap)