Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[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

[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 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(" "); }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Probabilistic Databases

Authors: Dan Suciu, Dan Olteanu, Christopher Re, Christoph Koch

1st Edition

3031007514, 978-3031007514

More Books

Students also viewed these Databases questions