From 35f21f3b1bfb7692a87763e0044f4aff8bc5114d Mon Sep 17 00:00:00 2001 From: nik Date: Mon, 9 Apr 2018 12:12:30 +0300 Subject: [PATCH] Refactored SelectionSort --- Sorts/SelectionSort.java | 55 +++++++++++++++------------------------- 1 file changed, 21 insertions(+), 34 deletions(-) diff --git a/Sorts/SelectionSort.java b/Sorts/SelectionSort.java index 21fa7151..bc0201ce 100644 --- a/Sorts/SelectionSort.java +++ b/Sorts/SelectionSort.java @@ -1,73 +1,60 @@ +package Sorts; + +import static Sorts.SortUtils.*; + /** * * @author Varun Upadhyay (https://github.com/varunu28) * */ -public class SelectionSort { +public class SelectionSort implements SortAlgorithm { /** * This method implements the Generic Selection Sort * * @param arr The array to be sorted - * @param n The count of total number of elements in array * Sorts the array in increasing order **/ - - public static > void SS(T[] arr, int n) { - - for (int i=0;i> T[] sort(T[] arr) { + int n = arr.length; + for (int i = 0; i < n - 1; i++) { // Initial index of min int min = i; - for (int j=i+1;j 1 4 6 9 12 23 54 78 231 - for(int i=0; i a b c d e - for(int i=0; i