write a selection sort program in R languageSolutionBelow is
write a selection sort program in R language
Solution
Below is the selection sort implemented in R language:
 selectionsortR = function(v) {
 N = length(v)
 
 for(i in 1:N) {
 min = i
 
 for(j in i:N) {
 if(v[j] < v[min]) {
 min = j
 }
 }
 temp = v[i]
 v[i] = v[min]
 v[min] = temp
 }
 return(v)
 }
Thank you.

