Design a Python program to sort the given list using insertion sort. [3,8,15,2,6,10]
- User
Design a Python program to sort the given list using insertion sort. [3,8,15,2,6,10]
Assistant
Algorithm Logic:
- Outer Loop: Iterate from the second element (index 1) to the end of the list. We assume the first element is already sorted.
- Key Selection: Pick the current element to be inserted (let's call it
key). - Compare the with elements in the sorted sub-list (to its left), moving from right to left.