Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using the following template, make the necessary modifications to make the outpu

ID: 3935537 • Letter: U

Question

Using the following template, make the necessary modifications to make the outputs match. For example: When the input is:

The output is:

Lab ubble sort Submission 11.8.1: B Load default template... File: main.py 1 def bubbleClist): 2 count = 0 count2 = 0 # YOUR CODE GOES HERE 4 # TO HERE return (count, count2) 7 9 list = [] 10 while True: 11 val = input() 12 13 14list.append(val) 15 16 counts = bubble(list) 17 print(list) 18 print("It took", counts[0], "swaps and" 19 orint(counts11. '' comparisons to sort it.") if val "exit": break

Explanation / Answer

Paste it along comment. And define new function swap.

for i in range( len( list ) ):

    for k in range( len( list ) - 1, i, -1 ):

    count2 = count2+1

    if ( A[k] < A[k - 1] ):

        swap( A, k, k - 1 )

       count = count + 1

def swap( A, x, y ):

  tmp = A[x]

  A[x] = A[y]

  A[y] = tmp