Fill This Form To Receive Instant Help
Homework answers / question archive / 1) Trace through this Short bubble sort algorithm
1) Trace through this Short bubble sort algorithm. Create a trace table. trace table should include all the variables that get updated throughout the algorithm. How many passes does it do?
def shortBubbleSort(alist):
exchanges = True
passnum = len(alist)-1
while passnum > 0 and exchanges:
exchanges = False
for i in range(passnum):
if alist[i]>alist[i+1]:
exchanges = True
temp = alist[i]
alist[i] = alist[i+1]
alist[i+1] = temp
passnum = passnum-1
alist=[10,50,40,30,20,90,80]
shortBubbleSort(alist)
print(alist)
please answer the question step by step