import random
# санамсаргүй утга бүхий лист үүсгэх хэсэг
my_list = []
max_value = 0
for n in range(10000):
var01 = random.randint(0, 200)
my_list.append(var01)
# print(my_list)
# Buble Sort
def bubbleSort(arr):
n = len(arr)
# Листийн элементүүдийг дамжих
for i in range(n-1):
# Last i elements are already in place
for j in range(0, n-i-1):
# traverse the array from 0 to n-i-1
# Swap if the element found is greater
# than the next element
if arr[j] > arr[j+1] :
arr[j], arr[j+1] = arr[j+1], arr[j]
return arr
No comments:
Post a Comment