I didn't understand the iteration of insertion sort.
Answers
Answer:
First the list is separated as sorted and unsorted list.
Step 1:Initially sorted list is empty. and unsorted list contains all the values.
Step 2:First value from the unsorted list moved to the sorted list.others remain same in unsorted list.
step 3: Next element from the unsorted list is want to move to the sorted list .
if current value is greater than the sorted list element then current value is removed from the unsorted list and added next to previous element.else added before.
step 4:This process happen for all elements must be enter into sorted list
Explanation:
15 12 14 16
sorted list: unsorted list:
15 12 14 16
now checks 15 >12
so
12 15 14 16
now checks 14>12 and 14<15
so
12 14 15 16
now checks 16 with all.
so
12 14 15 16
unsorted list is empty now.
so all the elements are sorted.
hope this is helpful