Question: Translate C++ Merge function into MIPS assembly language. Clarification: The objective of this problem is to translate the merge method written in C++ (which takes

Translate C++ Merge function into MIPS assembly language.

Clarification:

The objective of this problem is to translate the merge method written in C++ (which takes an array of two, adjacent sorted arrays i.e. [1,2,3,4,5,12,13,14,15,16] and sorts the array into one sorted array) into MIPS Assembly language. So essentially, a conversion of the code written above into MIPS

int c[100]; //c[100] is a global array

void merge(int a[], int low, int high, int mid){

int i, j, k;

i = low;

k = low;

j = mid + 1;

while (i <= mid && j <= high){

if (a[i] < a[j]) {

c[k] = a[i];

k++;

i++;

}

else {

c[k] = a[j];

k++; j++;

}

}

while (i <= mid){

c[k] = a[i];

k++;

i++;

}

while (j <= high){

c[k] = a[j];

k++;

j++;

}

for (i = low; i < k; i++){

a[i] = c[i];

}

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!