all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
|
|
@ -0,0 +1,13 @@
|
|||
def insertionSort = { list ->
|
||||
|
||||
def size = list.size()
|
||||
(1..<size).each { i ->
|
||||
def value = list[i]
|
||||
def j = i - 1
|
||||
for (; j >= 0 && list[j] > value; j--) {
|
||||
print "."; list[j+1] = list[j]
|
||||
}
|
||||
print "."; list[j+1] = value
|
||||
}
|
||||
list
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
println (insertionSort([23,76,99,58,97,57,35,89,51,38,95,92,24,46,31,24,14,12,57,78,4]))
|
||||
println (insertionSort([88,18,31,44,4,0,8,81,14,78,20,76,84,33,73,75,82,5,62,70,12,7,1]))
|
||||
Loading…
Add table
Add a link
Reference in a new issue