Question: You will write two MIPS programs called simplesort.asm and recsort.asm, and submit them for grading to Autolab. Your Autolab score is only part of your

You will write two MIPS programs called simplesort.asm and recsort.asm, and submit them for grading to Autolab. Your Autolab score is only part of your overall grade for the assignment. Take care to follow all of the style guidelines.

Sample Input

7 2 5 1 -7 2 4 16

Sample Output

The elements sorted in ascending order are: -7, 1, 2, 2, 4, 5, 16

CS 270 MIPS Programming Page 2 of 3

1 Simple Sort

Write a MIPS program that uses an implementation of selection sort to sort an array of numbers. The values of the array will be given to you via standard input and separated by newlines. The first number will be the number of elements in the array and followed by the elements of the array in order. You can assume that there will be at least one, and no more than 20 numbers in the array. Each number will fit in a signed 4 byte integer. After sorting the numbers, you should write them to standard out in increasing order. Your code should be able to handle an array with numbers that have the same value. For full credit, your code must be a valid translation of the selection sort implementation on the next page of this document. Your code must include a function that performs the sorting. That function should not call any other functions. The array should be declared in the static data portion of memory.

Selection Sort Implementation - C

void selection sort(int arr[], int len) {

int i, j, tmp, min, Index;

for (i=0; i

minIndex = i ;

for (j=i+1; j

if (arr[minIndex] > arr[j]) {

minIndex = j ;

}

}

if (minIndex != i) {

tmp = arr[minIndex];

arr[minIndex] = arr[i];

arr[i] = tmp; } } }

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!