Unformatted text preview: out = vec; else end end function out = slowSort(vec) %Given a 1xN array of scalars (a vector), write a function slowSort %that recursively sorts the vector in ascending order and outputs this %sorted vector. %usage: out = slowSort(vec) if isempty(vec) %initial condition to check and see if the original vector and all of %the recursive vectors are empty out = ; %terminating condition; sets the output equal to an empty vector if vec %is an empty vector else out = [min(vec) slowSort(vec(min(vec)~=vec))]; %concatenates the minimum with the recursive function to continue to %keep increasing the order end end...
View Full Document
This note was uploaded on 10/21/2010 for the course CS 1371 taught by Professor Stallworth during the Spring '08 term at Georgia Tech.
- Spring '08