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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started