0

I coded it myself first and tried copy-paste'ing and implementing other quicksort codes from the internet. None of those worked.

void quickSort (char** tmpDictionary, int left, int right) {
    int pivot, i, j;
    char tmp[BUFFER_LENGTH];
    if (right > left) {
        pivot = left;
        i = left;
        j = right;
        while (i < j) {
            while ((strcmp(tmpDictionary[pivot], tmpDictionary[i]) >= 0) && (right > i)) {
                i++;
            }

            while ((strcmp(tmpDictionary[j], tmpDictionary[pivot]) == 1)) {
                j--;
            }

            if (i < j) {
                printf("%s ile %s yer degistiriyor.\n", tmpDictionary[i], tmpDictionary[j]);
                strcpy(tmp, tmpDictionary[i]);
                strcpy(tmpDictionary[i], tmpDictionary[j]);
                strcpy(tmpDictionary[j], tmp);
                quickSort(tmpDictionary, left, j-1);
                quickSort(tmpDictionary, j+1, right);
            }
        }
    }
}

What am I doing wrong here?

J-Alex
  • 6,881
  • 10
  • 46
  • 64

0 Answers0