diff --git a/Doc/library/heapq.rst b/Doc/library/heapq.rst index 462b65bc7afba4..52d96600c087c0 100644 --- a/Doc/library/heapq.rst +++ b/Doc/library/heapq.rst @@ -306,12 +306,12 @@ entry as removed and add a new entry with the revised priority:: Theory ------ -Heaps are arrays for which ``a[k] <= a[2*k+1]`` and ``a[k] <= a[2*k+2]`` for all +Min-heaps are arrays for which ``a[k] <= a[2*k+1]`` and ``a[k] <= a[2*k+2]`` for all *k*, counting elements from 0. For the sake of comparison, non-existing -elements are considered to be infinite. The interesting property of a heap is -that ``a[0]`` is always its smallest element. +elements are considered to be infinite. The interesting property of a min-heap is +that ``a[0]`` is always its smallest element. Max-heaps satisfy the reverse invariant. -The strange invariant above is meant to be an efficient memory representation +The strange min-heap invariant is meant to be an efficient memory representation for a tournament. The numbers below are *k*, not ``a[k]``: .. figure:: heapq-binary-tree.svg