diff --git a/BubbleSort.py b/BubbleSort.py new file mode 100644 index 0000000..b4510ad --- /dev/null +++ b/BubbleSort.py @@ -0,0 +1,21 @@ +import random +import time + +zahlen = [] +anzahlElemente = 20 + +for i in range(anzahlElemente): + zahlen.append(random.randint(1, anzahlElemente-1)) +print(zahlen) + +start = time.time() + +for k in range(1, anzahlElemente): + for i in range(anzahlElemente -1): + if zahlen[i] > zahlen[i+1]: + zahlen[i], zahlen[i+1] = zahlen[i+1], zahlen[i] + +stopp = time.time() +print(zahlen) +print() +print('{0:5.3f}s'.format(stopp-start)) \ No newline at end of file