The next definition is from Wikipedia: "In computer science, a Selection sort is a sorting algorithm , specifically an in-place comparison sort. It has O(n 2 ) time complexity, making it inefficient on large lists, and generally performs worse than the similar insertion sort. Selection sort is noted for its simplicity, and also has performance advantages over more complicated algorithms in certain situations, particularly where auxiliary memory is limited." It mentions also they are variants of this algorithm: heapsort, cocktail sort, bingo sort. Also there is a table where n is the number of records to be sorted. The columns "Average" and "Worst" give the time complexity in each case. Name Best Average Worst Selection sort Now, here the code in Java (take in account that I will implement the same interface and use the same tool class and it was defined in Insertion Sort Algorithm ). package melg.algorithms.sorting; /** * @aut
I've started to study more about algorithms. I think that it will be an excellent challenge and great experience. I found this course in MIT Open CourseWare website : " Introduction to Algorithms (SMA 5503) " , and I'm studying from this resource and also I've bought the related book to this course. Well, I'm going to post entries related to algorithms in Java, Groovy and Python language (my new lovers :) ). For Java coding I'm going to create an interface to be implemented for all my algorithm classes. package melg.algorithms.sorting; public interface ISorting { long[] makeSorting(long[] array, boolean debug); String getStats(); } Also I'll use this tool class, in order to be used for debugging purpose: package melg.algorithms.sorting; public class SortUtilAlgorithm { /** * Prints in the console the items of the array object * * @param array * the array object. */ public static void showArray(long[] array)