mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-05-02 06:46:18 -04:00
Update heapify.py
This commit is contained in:
parent
e8882c2da0
commit
f595c7b2cf
1 changed files with 7 additions and 0 deletions
|
@ -2,6 +2,13 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# author: bt3gl
|
||||
|
||||
# python's built-in heap differs from the standard implementation of a heap
|
||||
# in two ways. firstly, it uses zero-based indexing, so it stores the root
|
||||
# node at index zero instead of the size of the heap. secondly, the built-in
|
||||
# module does not offer a direct way to create a max heap, instead, we must
|
||||
# modify the values of each eelement when inserting in the heap, and when
|
||||
# removing it from the heap.
|
||||
|
||||
import heapq
|
||||
|
||||
min_heap = [3,1,2]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue