擅长:python、mysql、java
<p><code>>></code>是右移位运算符。它删除最右边的位,这与除以2并忽略余数相同。所以这行可能是<code>parentpos = (pos - 1) // 2</code>。在</p>
<p>Python的堆是从零开始的,因此节点<em>i</em>在<code>2 * i + 1</code>和{<cd4>}处有子节点。它的父节点位于<code>(i - 1) // 2</code>。在</p>
<p>siftdown的作用是向上移动一个值(通过与父对象交换),直到父对象小于子对象。在</p>