# Answer to Question #64542 in Python for Abdulganiyu Kamaldeen

Question #64542

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?

Expert's answer

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)

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 orderand get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

## Comments

## Leave a comment