堆插入时14,15这两行代码的意义
14. i = j; //15. j = (i - 1) / 2;
cpp] view plain copy
01.// 新加入i结点 其父结点为(i - 1) / 2
02.void MinHeapFixup(int a[], int i)
03.{
04. int j, temp;
05.
06. temp = a[i];
07. j = (i - 1) / 2; //父结点
08. while (j >= 0 && i != 0)
09. {
10. if (a[j] <= temp)
11. break;
12.
13. a[i] = a[j]; //把较大的子结点往下移动,替换它的子结点
14. i = j;
15. j = (i - 1) / 2;
16. }
17. a[i] = temp;
18.}