diff options
| author | Shinya Sato <shinnya.sato@gmail.com> | 2022-05-30 20:36:38 +0900 |
|---|---|---|
| committer | Shinya Sato <shinnya.sato@gmail.com> | 2022-05-30 20:36:38 +0900 |
| commit | e18b27f43ac23689822d4aaaaa3e8d550e41017a (patch) | |
| tree | 262150d7ad6abc6759f41a7adbb6dec4a7c90cb5 /comparison/Python/bsort-20000.py | |
| parent | 04cbbcc0649dfc80d8dbf8c4bc567285df7a9da4 (diff) | |
| download | inpla-e18b27f43ac23689822d4aaaaa3e8d550e41017a.tar.gz inpla-e18b27f43ac23689822d4aaaaa3e8d550e41017a.zip | |
v0.8.2-2
Diffstat (limited to 'comparison/Python/bsort-20000.py')
| -rw-r--r-- | comparison/Python/bsort-20000.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/comparison/Python/bsort-20000.py b/comparison/Python/bsort-20000.py new file mode 100644 index 0000000..22cc8a7 --- /dev/null +++ b/comparison/Python/bsort-20000.py @@ -0,0 +1,31 @@ +# 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 + + +def validation(alist): + for i in range(len(alist)-1): + if (alist[i] > alist[i+1]): + return False + + return True + + + +a=mkRandList(20000) +bubblesort(a) +print(validation(a)) |
