mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-05-02 06:46:18 -04:00
Create heapify.py
This commit is contained in:
parent
cf0a3cd358
commit
e8882c2da0
1 changed files with 11 additions and 0 deletions
11
heaps/heapify.py
Normal file
11
heaps/heapify.py
Normal 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)
|
Loading…
Add table
Add a link
Reference in a new issue