From ea8f0940f041d33c0085bed59773093333a4fd99 Mon Sep 17 00:00:00 2001 From: ame Date: Sun, 15 Oct 2023 22:45:54 -0500 Subject: init --- t.lua | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 t.lua (limited to 't.lua') diff --git a/t.lua b/t.lua new file mode 100644 index 0000000..5e6dc45 --- /dev/null +++ b/t.lua @@ -0,0 +1,40 @@ +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.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]) +end + +print(table.concat(l1) == table.concat(l2)) ]]-- -- cgit v1.2.3