private void heapify_up(int i) { while (i > 0) { int j = parent(i); if (costs[i] < costs[j]) { heapswap(i, j); i = j; } else { return; } } }