Suppose you have the following list of numbers to sort: [19, 1, 9, 7, 3, 10, 13, 15, 8, 12] which list represents the partially sorted list after three complete passes of bubble sort?
def bubbleSort(arr, counter):
length = len(arr) - 1
while counter>0:
for i in range(length):
if arr[i] > arr[i+1]:
arr[i], arr[i+1] =arr[i+1], arr[i]
counter-=1
v= [19, 1, 9, 7, 3, 10, 13, 15, 8, 12]
bubbleSort(v,3)
print (v)
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
Python