blob: 32269c8dcf9dc327255541c781cc0f5e59c13cb3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
require "llib"
local a = llib.array
local tab = {}
math.randomseed(os.time())
for i=1,19 do
table.insert(tab,math.random(1,999));-- + math.random(1,999));
end
--print("length of 99999 :\n")
--time = os.clock()
--local l1 = a.quicksort(tab)
--print("quick sort took "..os.clock()-time.."s")
--time = os.clock()
--local l2 = a.mergesort(tab)
--print("merge sort took "..os.clock()-time.."s")
--time = os.clock()
--local l3 = a.shellsort(tab)
--print("shell sort took "..os.clock()-time.."s")
--time = os.clock()
--local l4 = a.bubblesort(tab)
--print("bubble sort took "..os.clock()-time.."s")
--time = os.clock()
--local l5 = a.heapsort(tab)
--print("heap sort took "..os.clock()-time.."s")
--time = os.clock()
local l6 = a.shellsort(tab)
for l,i in pairs(l6) do
print(l6[l])
end
print(a.sum(l6))
|