Data update
This commit is contained in:
parent
81fd053722
commit
52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions
|
|
@ -0,0 +1,15 @@
|
|||
type StoogeSorter
|
||||
fun stoogeSort ← void by List list, int i, int j
|
||||
if list[j] < list[i] do list.swap(i, j) end
|
||||
if j - i + 1 > 2
|
||||
var t ← (j - i + 1) / 3
|
||||
stoogeSort(list, i, j - t)
|
||||
stoogeSort(list, i + t, j )
|
||||
stoogeSort(list, i, j - t)
|
||||
end
|
||||
end
|
||||
fun sort ← <List list|stoogeSort(list, 0, list.length - 1)
|
||||
type Main
|
||||
List sample ← int[1, 4, 5, 3, -6, 3, 7, 10, -2, -5, 7, 5, 9, -3, 7]
|
||||
StoogeSorter.sort(sample)
|
||||
writeLine(sample)
|
||||
|
|
@ -9,6 +9,8 @@ proc stsort left right . d[] .
|
|||
stsort left right - t d[]
|
||||
.
|
||||
.
|
||||
d[] = [ 1 4 5 3 -6 3 7 10 -2 -5 ]
|
||||
for i = 1 to 100
|
||||
d[] &= random 1000
|
||||
.
|
||||
stsort 1 len d[] d[]
|
||||
print d[]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue