Descending selection sort with output during execution

Write the function selection_sort_descend_trace() that takes an integer list and sorts the list into descending order. The function should use nested loops and output the list after each iteration of the outer loop, thus outputting the list N-1 times (where N is the size).

Complete __main__ to read in a list of integers, and then call selection_sort_descend_trace() to sort the list.

Descending selection sort with output during execution Write the function selectionsortdescendtrace that takes an integer list and sorts the list into descendin class=

Respuesta :

Taking the input as a string, slicing it with a space as the delimiter, turning the divided portion into an integer, and then appending to the list.

Explanation:

def selection_sort_descend_trace(numbers):

i=len(numbers)

print("Output: ")

for num in range(0,i-1):# traversing from 0 to N-2, total N-1 iterations

val=numbers[num]

start=num+1

end=i

t=0

for j in range(start,end):

if(val<numbers[j]):

remember=j

val=numbers[j]

t=1

if(t==1):# swaping onlf if greater number is available

temp=numbers[num]

numbers[num]=val

numbers[remember]=temp

for p in range(i):# printing

print(numbers[p],end=' ')

print("\n")

if __name__ == "__main__":

print("Enter the integers separated by space: ")

numbers=[int(x) for x in input().split(' ')]

selection_sort_descend_trace(numbers)

For further details about the explanation, click here:

https://brainly.com/question/15728245

#SPJ1

ACCESS MORE
ACCESS MORE
ACCESS MORE
ACCESS MORE