Insert sort pseudo code for I <--1 to n-1 for J <--i-1 to 0 if a[i] > a[j] breakif j!=i-1temp <--a[i]for k &L t;--i to j+2 A[k] <--a[k-1]a[j+1] <--Temp
Inserting a sort flowchart
Insert Sort Code Implementation
/*** to sort an array a[],the length of a shouldn ' t being negative* and after the sort,the content of array a have changed.* * @parm a[] The array to be sorted* @parm len the length of the array A * * @return there is no return,only to sort the ARRA Y*/void insertsort (int a[], int len) {int temp;//used to save the value of a[i]/*** to find the place of the element which Index is i* we think, the first element a[0] is on the right place* next we find the place for elements which index is From 1 to n-1*/for (int i = 1, i < n; i++) {/*** We would find the place for the element which index is I if* the value of A[i] is bigger the a[j],so we break to does next thing*/for (int j = i-1; J >= 0; j--) {if (A[i] > A[j]) break;} /*** If the value J is not equals to I-1,we would know then the place of a[i]* are not i-1,so we had to move all the Eleme NT which index is bigger than j* and next we put element A[i] to the place which index is j+1*/if (j!=i-1) {temp = A[i];for ( int k = i; K > j+1; k--) {a[K] = a[k-1];} A[J+1] = temp;}}}
Insert sort-Pseudo code--Flowchart--Program