code: public static void siftDown(float[] arr, int k, int n) {
          while (2*k <= n) {
              int j = 2 * k;
              if (j < n && arr[j] < arr[j + 1]) {
                  j++;
              }
              if (arr[k] >= arr[j]) {
                  break;
              }
              swap(arr, k, j);
              k = j;
          }
      }
docs: To restore the max-heap condition when a node's priority is decreased.
  We move down the heap, exchanging the node at position k with the larger
  of that node's two children if necessary and stopping when the node at
  k is not smaller than either child or the bottom is reached. Note that
  if n is even and k is n/2, then the node at k has only one child -- this
  case must be treated properly.