all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
|
|
@ -0,0 +1,16 @@
|
|||
List do(
|
||||
gnomeSortInPlace := method(
|
||||
idx := 1
|
||||
while(idx <= size,
|
||||
if(idx == 0 or at(idx) > at(idx - 1)) then(
|
||||
idx = idx + 1
|
||||
) else(
|
||||
swapIndices(idx, idx - 1)
|
||||
idx = idx - 1
|
||||
)
|
||||
)
|
||||
self)
|
||||
)
|
||||
|
||||
lst := list(5, -1, -4, 2, 9)
|
||||
lst gnomeSortInPlace println # ==> list(-4, -1, 2, 5, 9)
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
List do(
|
||||
gnomeSortInPlace := method(
|
||||
idx1 := 1
|
||||
idx2 := 2
|
||||
|
||||
while(idx1 <= size,
|
||||
if(idx1 == 0 or at(idx1) > at(idx1 - 1)) then(
|
||||
idx1 = idx2
|
||||
idx2 = idx2 + 1
|
||||
) else(
|
||||
swapIndices(idx1, idx1 - 1)
|
||||
idx1 = idx1 - 1
|
||||
)
|
||||
)
|
||||
self)
|
||||
)
|
||||
|
||||
lst := list(5, -1, -4, 2, 9)
|
||||
lst gnomeSortInPlace println # ==> list(-4, -1, 2, 5, 9)
|
||||
Loading…
Add table
Add a link
Reference in a new issue