all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
|
|
@ -0,0 +1,11 @@
|
|||
selectionsort.loop <- function(x)
|
||||
{
|
||||
lenx <- length(x)
|
||||
for(i in seq_along(x))
|
||||
{
|
||||
mini <- (i - 1) + which.min(x[i:lenx])
|
||||
start_ <- seq_len(i-1)
|
||||
x <- c(x[start_], x[mini], x[-c(start_, mini)])
|
||||
}
|
||||
x
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
selectionsort.rec <- function(x)
|
||||
{
|
||||
if(length(x) > 1)
|
||||
{
|
||||
mini <- which.min(x)
|
||||
c(x[mini], selectionsort(x[-mini]))
|
||||
} else x
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue