initial commit
This commit is contained in:
commit
39f56a3b10
83 files changed
+3583
No files matched your search
@@ -0,0 +1,39 @@
|
||||
import time
|
||||
|
||||
list_of_names = ['Alexander', 'Maximilianosohn', 'Peter', 'Jan',
|
||||
'Paul', 'Sabine', 'Franzi von Ulmen']
|
||||
|
||||
def bublesort(lst):
|
||||
for element in range(len(lst) - 1):
|
||||
if element != len(lst):
|
||||
if lst[element] > lst[element+1]:
|
||||
lst[element], lst[element+1] = lst[element+1], lst[element]
|
||||
print(f"'{lst[element]}' is greater then '{lst[element + 1]}', their postions are now swaped")
|
||||
print(f"current state of the list: {lst}")
|
||||
print()
|
||||
time.sleep(3)
|
||||
if lst != sorted(lst):
|
||||
bublesort(lst)
|
||||
print("bubble sort calls itself")
|
||||
print()
|
||||
time.sleep(2)
|
||||
return lst
|
||||
|
||||
print("Bubble sort is a simple sorting algorithm, that recursively iterates over the entire list")
|
||||
print()
|
||||
time.sleep(4)
|
||||
print("Each letter in the alphabet has its own value, the later they appear in the alphabet, the higher their value")
|
||||
print()
|
||||
time.sleep(4)
|
||||
print("If a value is greater then the next value in the list, their positions will be swapped")
|
||||
print()
|
||||
time.sleep(4)
|
||||
print("This Process is repeated until all elements in the list are sorted.")
|
||||
print()
|
||||
time.sleep(4)
|
||||
print("The following messages will show the process in detail")
|
||||
print()
|
||||
time.sleep(3)
|
||||
print(bublesort(list_of_names))
|
||||
|
||||
|
||||
Reference in new issue
Block a user