4. 1. The list is divided in to two parts
which is sorted and unsorted.
2. In each phase, the first element of
unsorted part is picked up,transferred
to sorted list and inserted at the
appropriate place.
3. A list of n elements will take atmost
n-1 passes to sort the data.
5. 36 12 30 23 10
Let us consider the list which is given below:
The above list is divided in to two parts which
is sorted and unsorted.
6. 36 12 30 23 10
Here, the first element is sorted. That is,36 is in
the sorted list, whereas other elements are in the
unsorted list. Next, we have to select the first
element from the unsorted list and inserted at the
appropriate place in the sorted list.
7. 36 12 30 23 10
Now, we have selected the first
element from the unsorted list.
Then, we have to insert in to the
sorted list.
8. 36 12 30 23 10
We have inserted the element in the
appropriate place. Now the sorted
list consists of two elements which is
12,36.
9. 12 36 30 23 10
Again, we have to select the first element from
the unsorted list and insert at the appropriate
place.
PASS 1
10. 12 36 30 23 10
Now ,the sorted list has three elements in it.
Again, select first element from the unsorted list
and insert at the appropriate place.
PASS 2
11. 12 30 36 23 10
We have inserted at the correct position. Now
the sorted list has four elements in it, whereas
the unsorted list has one element. Select ,the
element from the unsorted list and insert at the
appropriate place.
PASS 3
12. 12 23 30 36 10
Now, we have inserted the element at the
correct position. Thus the list rearranged in to
sorted one.
PASS 4
13. 10 12 23 30 36
The sorted list is given below: