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

Function Name: slowSort Inputs (1): - (double) A 1xN array ofscalars Outputs (1)

ID: 3617338 • Letter: F

Question

Function Name: slowSort Inputs (1): - (double) A 1xN array ofscalars Outputs (1): - (double) The input array sorted inascending order
Function Description: Given a 1xN array of scalars (a vector), write a functionslowSort that recursively sorts the vector in ascending order andoutputs this sorted vector.
Constraints: You MUST use recursion to solve this problem
Test Cases:
   a = slowSort([13 -4 0 17 25 3 18 48]);    a => [-4 0 3 13 17 18 2548]
b = slowSort([86 48 53 -20 -30 4 7 8]); b => [-30 -20 4 7 8 48 53 86]
Function Name: slowSort Inputs (1): - (double) A 1xN array ofscalars Outputs (1): - (double) The input array sorted inascending order
Function Description: Given a 1xN array of scalars (a vector), write a functionslowSort that recursively sorts the vector in ascending order andoutputs this sorted vector.
Constraints: You MUST use recursion to solve this problem
Test Cases:
   a = slowSort([13 -4 0 17 25 3 18 48]);    a => [-4 0 3 13 17 18 2548]
b = slowSort([86 48 53 -20 -30 4 7 8]); b => [-30 -20 4 7 8 48 53 86]

Explanation / Answer

function A = slowSort(B) [m n]=size(B); %you can do error checking for m!=1 if(n>1)     i=find(B==min(B));     n=min(B);     B=[B(1,1:i-1) B(1,i+1:end)];     A=[n slowSort(B)]; else     A=B; end