PYTHON The following code implements this algorithm to sort a list of numbers in ascending order. But some code is missing as indicated by '?'.
def sort_in_place(list_num): for i in range(?): for j in range(?): if ?: temp = list_num[j] list_num[j] = list_num[i] list_num[i] = temp my_list = [23,1,45,20,13,-34] sort_in_place(my_list) print(my_list)
Modify the three lines of code in the program below so that the output is
[-34, 1, 13, 20, 23, 45]
def sort_in_place(list_num): for i in range(len(list_num)): for j in range(len(list_num)): if list_num[i]<list_num[j]: temp = list_num[j] list_num[j] = list_num[i] list_num[i] = temp my_list = [23,1,45,20,13,-34] sort_in_place(my_list) print(my_list)
Get Answers For Free
Most questions answered within 1 hours.