diff options
| author | Shinya Sato <shinnya.sato@gmail.com> | 2022-05-30 20:36:53 +0900 |
|---|---|---|
| committer | Shinya Sato <shinnya.sato@gmail.com> | 2022-05-30 20:36:53 +0900 |
| commit | e9db0870164cfec10aa219cc0898c30f6a888f53 (patch) | |
| tree | 262150d7ad6abc6759f41a7adbb6dec4a7c90cb5 /comparison/Python/bsort-20000.py | |
| parent | bd540962efa674bb70dc9ada49393db54616dcbf (diff) | |
| parent | e18b27f43ac23689822d4aaaaa3e8d550e41017a (diff) | |
| download | inpla-e9db0870164cfec10aa219cc0898c30f6a888f53.tar.gz inpla-e9db0870164cfec10aa219cc0898c30f6a888f53.zip | |
Merge branch 'develop'
Diffstat (limited to '')
| -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)) |
