摘要:
堆的概念:它是一棵完全二叉树。每个结点大于或等于它的任意一个孩子。(最大堆)堆排序:堆可以存储在一个ArrayList或数组中,树根在位置0处,它的两个孩子在位置1和2处。对于位置 i 处的结点它的左孩子在位置2i + 1 处,它的右孩子在2i+ 2 处,而它的父亲在位置(i-1)/2 处。添加一个新结点Let the last node be the current node;while(the current node is greater than its parent){Swap the current node with its parent;Now the current node 阅读全文