all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
|
|
@ -0,0 +1,16 @@
|
|||
insertionsort <- function(x)
|
||||
{
|
||||
for(i in 2:(length(x)))
|
||||
{
|
||||
value <- x[i]
|
||||
j <- i - 1
|
||||
while(j >= 1 && x[j] > value)
|
||||
{
|
||||
x[j+1] <- x[j]
|
||||
j <- j-1
|
||||
}
|
||||
x[j+1] <- value
|
||||
}
|
||||
x
|
||||
}
|
||||
insertionsort(c(4, 65, 2, -31, 0, 99, 83, 782, 1)) # -31 0 1 2 4 65 83 99 782
|
||||
Loading…
Add table
Add a link
Reference in a new issue