Question: Need help converting my correct C code for quicksort (recursive) to MIPS assembly My C code is: #include void quicksort (int [], int, int );
Need help converting my correct C code for quicksort (recursive) to MIPS assembly
My C code is:
#include
void quicksort (int [], int, int );
int main() {
int array[50];
int size, i;
scanf("%d", &size);
for (i = 0; i < size; i++) {
scanf("%d", &array[i]);
}
quicksort(array, 0, size-1);
for (i = 0; i < size; i++) {
printf("%d ", array[i]);
}
return 0;
}
void quicksort (int array[], int low, int high) {
int pivot, i, j, temporary;
if (low < high) {
pivot = low;
i = low;
j = high;
while (i < j) {
while (array[i] <= array[pivot] && i <= high) {
i ++;
}
while( array[j] > array[pivot] && j >=low) {
j--;
}
if (i < j) {
temporary = array[i];
array[i] = array[j];
array[j] = temporary;
}
}
temporary = array[j];
array[j] = array[pivot];
array[pivot] = temporary;
quicksort (array, low, j-1);
quicksort (array, j+1, high);
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
