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?
1
Expert's answer
2017-01-13T09:12:13-0500
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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS