Pivot값에 따라 코드가 다 각자 달라지는거 같은데..


Pivot이 어디서든 작동하는 코드는 없을까요??



이건 제가 중앙피봇으로 하는경우 짰는뎅


void quickSort(int arr[], int first, int last) { //퀵소트

    int temp_first = first, temp_last = last;  

    int tempnumber;

    int pivot = arr[(first + last) / 2]; //pivot 중앙값

    

    

    while (temp_first <= temp_last) {

        while (arr[temp_first] < pivot)/

            temp_first++;

        while (arr[temp_last] > pivot) 

            temp_last--;

        if (temp_first <= temp_last) {

            tempnumber = arr[temp_first]; 

            arr[temp_first] = arr[temp_last]; 

            arr[temp_last] = tempnumber; 

            temp_first++;  

            temp_last--;

        }

    };

    

    

    if (first < temp_last)

        quickSort(arr, first, temp_last);  //

    if (temp_first < last)

        quickSort(arr, temp_first, last);  //

}


여기서 뭘 건들여야, 전부 다될까요.. 재귀해서도 안될까봐 손을 못대ㅡㄴ데

while두번째에서 피봇까지 왔으면 stop하는식으로 하면될까싶은뎅.