private List<Integer> shrinkHeap(List<Integer> list) {

        for (int n = list.size() - 1; n >= 0; n--) {

            appUtil.swap(list, 0, n);
            int parent = 0;

            while (true) {
                int leftChild = 2 * parent + 1;

                if (leftChild >= n) break;

                int rightChild = leftChild + 1;

                int maxChild = leftChild;

                if (rightChild < n && list.get(leftChild).compareTo(list.get(rightChild)) < 0)
                    maxChild = rightChild;

                // swap child & parent if parent < child
                if (list.get(parent).compareTo(list.get(maxChild)) < 0) {
                    appUtil.swap(list, parent, maxChild);
                    parent = maxChild;
                } else {
                    break;
                }
            }
        }
        return list;
    }