Question: please help me to convert this quicksort in C code to MIPS version of it. below things are quicksort with c-code and unfinished MIPS quicksort

please help me to convert this quicksort in C code to MIPS version of it.

below things are quicksort with c-code and unfinished MIPS quicksort

please finish MIPS quicksort

#include

int data[] = {8,5,14,10,12,3,9,6,1,15,7,4,13,2,11}; int size = 15;

//Below functions is for debugging purpose only. Don't implement this /* void debug(){ int i; for(i=0;i printf("%d, ", data[i]);

printf(" "); } */

int partition(int * data, int start, int end){ int left=start; int right=end; int pivot=data[start];

while(left

while (data[right] > pivot){ right--; }

while((left < right) && (data[left] <= pivot)){ left++; }

if(left int temp = data[right]; data[right] = data[left]; data[left] = temp; } }

data[start]=data[right]; data[right]=pivot;

return right; }

void quick_sort(int *data, int start, int end){ int pivot_position;

if(start < end){ pivot_position = partition(data, start, end); quick_sort(data, start, pivot_position-1); quick_sort(data, pivot_position+1, end); } } void main(){ quick_sort(data,0,size-1); //debug(); }

---------------------------------------------------------------------------------------

.data data: .word 8,5,14,10,12,3,9,6,1,15,7,4,13,2,11 size: .word 15 #use below sample if above example is too large to debug #data: .word 4,2,5,3,1 #size: .word 5 .text

partition: # TODO: fill in your code here jr $ra

quick_sort: # TODO: fill in your code here jr $ra

main: la $a0, data #load address of "data"."la" is pseudo instruction, see Appendix A-66 of text book. addi $a1, $zero, 0 lw $a2, size #loads data "size" addi $a2, $a2, -1

addi $sp, $sp, -4 sw $ra, 0($sp)

jal quick_sort #quick_sort(data,0,size-1)

lw $ra, 0($sp) addi $sp, $sp, 4

jr $ra

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!