June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -0,0 +1,31 @@
|
|||
import extensions.
|
||||
import system'routines.
|
||||
|
||||
extension $op
|
||||
{
|
||||
stoogeSort
|
||||
= self stoogeSort(0, self length - 1).
|
||||
|
||||
stoogeSort(IntNumber i, IntNumber j)
|
||||
[
|
||||
if(self[j]<self[i])
|
||||
[
|
||||
self exchange(i,j)
|
||||
].
|
||||
if (j - i > 1)
|
||||
[
|
||||
int t := (j - i + 1) / 3.
|
||||
self stoogeSort(i,j-t).
|
||||
self stoogeSort(i+t,j).
|
||||
self stoogeSort(i,j-t).
|
||||
]
|
||||
]
|
||||
}
|
||||
|
||||
program =
|
||||
[
|
||||
var list := 0 to:15 repeat(:n)(randomGenerator eval(20)); toArray.
|
||||
|
||||
console printLine("before:", list).
|
||||
console printLine("after:", list stoogeSort).
|
||||
].
|
||||
Loading…
Add table
Add a link
Reference in a new issue