diff options
| author | ame <[email protected]> | 2023-10-16 01:44:07 -0500 |
|---|---|---|
| committer | ame <[email protected]> | 2023-10-16 01:44:07 -0500 |
| commit | feb025300ce464322f5e5400fb9b2b8a4e8a2a8a (patch) | |
| tree | 838556a76b11ef39f1809f6a56597a7dc655feda /t.lua | |
| parent | dace220aa3aa6aad30bc339b5bbd2b6f57da925c (diff) | |
use heap over stack
Diffstat (limited to 't.lua')
| -rw-r--r-- | t.lua | 19 |
1 files changed, 6 insertions, 13 deletions
@@ -3,8 +3,8 @@ local a = llib.array local tab = {} math.randomseed(os.time()) -for i=1,9999 do - table.insert(tab,math.random(1,999));-- + math.random(1,999)); +for i=1,19 do + table.insert(tab,math.random(1,99999));-- + math.random(1,999)); end print("length of 99999 :\n") @@ -17,9 +17,9 @@ 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 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") @@ -27,14 +27,7 @@ time = os.clock() local l6 = a.countingsort(tab) print("counting sort took "..os.clock()-time.."s") -for l,i in pairs(llib.array.reverse(l1)) do - --print(l1[l].." "..l2[l].." "..l3[l].." "..l4[l].." "..l5[l]) -end ---print(llib.array.greatest(l1)) ---local l2 = llib.array.reverse(llib.array.bubblesort(tab)) ---[[ aa for l,i in pairs(l1) do - print(l1[l].." "..l2[l]) + print(l1[l].." "..l2[l].." "..l3[l].." "..l5[l].." "..l6[l]) end -print(table.concat(l1) == table.concat(l2)) ]]-- |
