1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Apr 2013
Posts
2
Rep Power
0

#### Quicksort 2d array

Can anyone spot a problem with my quick sort implementation below? I have a 2d array and i would like to sort each row separately. Compiler gives this warning.

warning : conflicting types for q_sort[enabled by default]
notice: implicit declaration of q_sort was here

Code:
```void quickSort(int (*E)[10000], int array_size)
{
int i;
for (i=0;i<array_size;i++)
q_sort(E[i], 0, array_size - 1);
}

void q_sort(int* E, int left, int right)
{
int pivot, l_hold, r_hold;
l_hold = left;
r_hold = right;
pivot = E[left];
while (left < right)
{
while ((E[right] >= pivot) && (left < right))
right--;
if (left != right)
{
E[left] = E[right];
left++;
}
while ((E[left] <= pivot) && (left < right))
left++;
if (left != right)
{
E[right] = E[left];
right--;
}
}
E[left] = pivot;
pivot = left;
left = l_hold;
right = r_hold;
if (left < pivot)
q_sort(E, left, pivot-1);
if (right > pivot)
q_sort(E, pivot+1, right);
}```
2. Yes, the best thing to do is prototype q_sort() before you call it.
3. Rearrange your source so that q_sort appears before quickSort. I don't know otherwise if your quick sort works. At a glance it appears to have correct features.

You don't need all that other apparatus and multi-dimensional arrays to get the warning message. This-'ll-do:
Code:
```void f(void) {
g("");
}
float g(char*,...);```
4. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Apr 2013
Posts
2
Rep Power
0
ok, thanks! Another question, i have this
L[j-1] = L[j-1]++;

and this

L[min] = L[min]++;

which gives me warnings

warning: operation on L[j-0x000000001] may be undefined
warning: operation on L[min] may be undefined

any ideas?
5. No clue. post 4 is the first post in thread in which "min" appears. In other words, NEED MORE INFORMATION.
6. Well in both cases, you either write

L[j-1]++;
L[min]++;

or

L[j-1] = L[j-1] + 1;
L[min] = L[min] + 1;