(Jan-14-2021, 07:49 PM)Serafim Wrote:Hi Serafim, in your "for loop" in this code, what is the purpose of the "1" in "(1, len(lst))," because as I was studying the code to see how everything worked together to sort the list, I couldn't figure out what the purpose of the "1" was, so I deleted it to see if the code would still work, and it still works?def selection_sort(lst): result = [] while lst: element = lst[0] for i in range(1, len(lst)): if lst[i] < element: element = lst[i] lst.remove(element) result.append(element) return result
Combine Two Recursive Functions To Create One Recursive Selection Sort Function
Users browsing this thread: 2 Guest(s)