From bd42abccd9e7c261f29c68791af68d47e0c3eb5c Mon Sep 17 00:00:00 2001 From: Varun Upadhyay Date: Thu, 7 Sep 2017 19:11:35 -0700 Subject: [PATCH] Updated SelectionSort.java Updated SelectionSort.java to its generic version --- Sorts/SelectionSort.java | 116 +++++++++++++++++++++++---------------- 1 file changed, 68 insertions(+), 48 deletions(-) diff --git a/Sorts/SelectionSort.java b/Sorts/SelectionSort.java index 955e7d65b9f7..21fa71514cc6 100644 --- a/Sorts/SelectionSort.java +++ b/Sorts/SelectionSort.java @@ -1,53 +1,73 @@ -import java.util.Scanner; - /** - * This class implements Selection Sort - * - * @author Unknown + * + * @author Varun Upadhyay (https://github.com/varunu28) * */ -class SelectionSort -{ - /** - * Main method - * - * @param args Command line arguments - */ - public static void main(String[] args) - { - int array[]=new int[6]; - Scanner input=new Scanner(System.in); - - //Input - System.out.println("Enter any 6 Numbers for Unsorted Array : "); - for(int i=0; i<6; i++) - { - array[i]=input.nextInt(); - } - - //Sorting - for(int i=0; i<6; i++) - { - int min=i; - for(int j=i+1; j<6; j++) - { - if(array[j]> void SS(T[] arr, int n) { + + for (int i=0;i 1 4 6 9 12 23 54 78 231 + for(int i=0; i a b c d e + for(int i=0; i