Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Selection sort is an algorithm that sorts a list of numbers. To sort the list in

ID: 2248487 • Letter: S

Question

Selection sort is an algorithm that sorts a list of numbers. To sort the list in ascending order, the algorithm works as follows: 1. Find the minimum value in the list. 2. Swap the minimum with the value in the first position of the list. 3. Repeat the steps above for the remainder of the list assuming that the first element in the list is the next element to the first element in the previous round. Effectively, the list is divided into two parts: the sublist of items that have already been sorted, and the sublist of items that will be sorted, occupying the remainder of the array. Write a MIPS function called sortList that sorts a list of integers in ascending order. The function takes two parameters: the address of the first element in the list and the number of elements in the list. In addition, write a print function called printOut that can be used to print any list of integer numbers. The function should take the list starting address and the number of elements in the list as parameters, and then it should print the elements in the screen separated by spaces. Further, assuming that the list of the numbers and the number of the elements in the list are stored in the memory at locations arr and n respectively, write a main function that calls the printOut function to print the elements before sorting, sorts them by calling the sortList function, and then calls the print function again to print the sorted elements.

Explanation / Answer

matlab programme:

clc;
clear all;
close all;
x=input('enter the sequence');
l=length(x);
for k=1:l
for i=1:l-1
if x(i)>x(i+1)
c=x(i+1);
x(i+1)=x(i);
x(i)=c;
else
x(i)=x(i);
x(i+1)=x(i+1);
end
end
end
disp(x)%sequence in ascending order

output:

enter the sequence[5 8 9 6 1 2 3 7 0 12 85 65]
0 1 2 3 5 6 7 8 9 12 65 85

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote