From 787dc13c837f0955fbd85b8f26a05d720d361333 Mon Sep 17 00:00:00 2001 From: Shinya Sato Date: Sun, 24 Oct 2021 23:04:45 +0900 Subject: Upload the comparison directory --- comparison/Python/bsort-40000.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 comparison/Python/bsort-40000.py (limited to 'comparison/Python/bsort-40000.py') diff --git a/comparison/Python/bsort-40000.py b/comparison/Python/bsort-40000.py new file mode 100644 index 0000000..25ea4c7 --- /dev/null +++ b/comparison/Python/bsort-40000.py @@ -0,0 +1,24 @@ +# http://www.geekviewpoint.com/python/sorting/bubblesort +import random + +def bubblesort(A): + for i in range(len(A)): + for k in range(len(A)-1, i, -1): + if (A[k] < A[k-1]): + tmp = A[k] + A[k] = A[k-1] + A[k-1] = tmp + + +def mkRandList(n): + a=[] + for i in range(1,n+1): + a.insert(0, random.randint(0,10000)) + return a + + + +a=mkRandList(40000) +bubblesort(a) + +#print(a) -- cgit v1.2.3