[Mips] Implement the pointer version of the bubble sort below in MIPS assembly.
ID: 3865093 • Letter: #
Question
[Mips] Implement the pointer version of the bubble sort below in MIPS assembly. The code supplied is in C (should be a pointer version) and should be rewritten in MIPS
#include <stdio.h>
void bubbleSort(int *num, int size)
{
int j;
int flag = 1; //set flag to true to begin first pass.
int temp; //holding variable.
while(flag)
{
flag = 0; //set flag to false awaiting a possible swap.
for(j = 0; j < size-1; j++)
{
if(*(num+j) < *(num+j+1)) //change to > for ascending sort
{
temp = *(num+j); //swap elements.
*(num+j) = *(num+j+1);
*(num+j+1) = temp;
flag = 1; //shows a swap occurred.
}
}
}
}
int main()
{
int array[] = {99, 88, 66, 77, 44, 55, 11, 33, 22};
printf("Before Sorting: ");
for(int i = 0; i < 9; i++)
printf("%d ", array[i]);
printf(" ");
bubbleSort(array, 9);
printf("After Sorting: ");
for(int i = 0; i < 9; i++)
printf("%d ", array[i]);
printf(" ");
}
Explanation / Answer
public class MockServiceDoubleArrayReader : IDoubleArrayReader { IEnumerable IDoubleArrayReader.GetDoubles() { Random r = new Random(); for(int i =0; iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.