public class CharuSort (public static void main (String [] args) (int [] sort = (4,6,3,9,5); Sort (sort); for (int i = 0; i System. out.print (sort [i] + '')...public class CharuSort (public static void main (String [] args) (int [] sort = (4,6,3,9,5);Sort (sort);for (int i = 0; i System.out.print (sort [i] + "");)public static void Sort (int [] sort) (int i; / / to scan timesint j; / / get elements as comparedfor (i = 1; i int temp; / / temp used for temporary datatemp = sort [i];j = i-1;while (j> = 0 & & temp sort [j +1] = sort [j]; / / put all the elements of a position pushed backj -;)sort [j +1] = temp; / / smallest element into the first position
Friday, September 3, 2010
Java Insertion Sort Algorithm
6:25 PM
ari sari
No comments
0 comments:
Post a Comment