(int a[])
| 2 | public class InsertionSort |
| 3 | { |
| 4 | void insert(int a[]) |
| 5 | { |
| 6 | int i, j, temp; |
| 7 | int n = a.length; |
| 8 | for (i = 1; i < n; i++) { |
| 9 | temp = a[i]; |
| 10 | j = i - 1; |
| 11 | |
| 12 | while(j>=0 && temp <= a[j]) |
| 13 | { |
| 14 | a[j+1] = a[j]; |
| 15 | j = j-1; |
| 16 | } |
| 17 | a[j+1] = temp; |
| 18 | } |
| 19 | } |
| 20 | void printArr(int a[]) |
| 21 | { |
| 22 | int i; |