Change the index of the element which was at position 0. Swap the element basically .
int element = arr [ best_index ] ; h [ element ] = initial_index ; int temp = arr [ best_index ] ; arr [ best_index ] = arr [ initial_index ] ; arr [ initial_index ] = temp ;