/** * Reads in a sequence of extended ASCII strings from standard input; * MSD radix sorts them; * and prints them to standard output in ascending order. * * @param args the command-line arguments */ public static void main(String[] args) { String[] a = StdIn.readAllStrings(); int n = a.length; sort(a); for (int i = 0; i < n; i++) StdOut.println(a[i]); }
/** * Reads in a sequence of extended ASCII strings or non-negative ints from standard input; * American flag sorts them; * and prints them to standard output in ascending order. * * @param args the command-line arguments */ public static void main(String[] args) { String[] a = StdIn.readAllStrings(); sort(a); // print results for (int i = 0; i < a.length; i++) StdOut.println(a[i]); }
/**/ public static void main(string[] strarr) { string[] array = StdIn.readAllStrings(); Knuth.shuffle(array); for (int i = 0; i < array.Length; i++) { StdOut.println(array[i]); } }
/**/ public static void main(string[] strarr) { string[] array = StdIn.readAllStrings(); int num = array.Length; MSD.sort(array); for (int i = 0; i < num; i++) { StdOut.println(array[i]); } }
/** * Reads in a sequence of strings from standard input, shuffles * them, and prints out the results. * * @param args the command-line arguments */ public static void main(String[] args) { // read in the data String[] a = StdIn.readAllStrings(); // shuffle the array Knuth.shuffle(a); // print results. for (int i = 0; i < a.length; i++) StdOut.println(a[i]); }
/** * Reads in a sequence of fixed-length strings from standard input; * 3-way radix quicksorts them; * and prints them to standard output in ascending order. * * @param args the command-line arguments */ public static void main(String[] args) { // read in the strings from standard input String[] a = StdIn.readAllStrings(); int n = a.length; // sort the strings sort(a); // print the results for (int i = 0; i < n; i++) StdOut.println(a[i]); }
/** * Reads in a sequence of fixed-length strings from standard input; * LSD radix sorts them; * and prints them to standard output in ascending order. * * @param args the command-line arguments */ public static void main(String[] args) { String[] a = StdIn.readAllStrings(); int n = a.length; // check that strings have fixed length int w = a[0].length(); for (int i = 0; i < n; i++) assert a[i].length() == w : "Strings must have fixed length"; // sort the strings sort(a, w); // print results for (int i = 0; i < n; i++) StdOut.println(a[i]); }
/** * Reads in a sequence of strings from standard input; quicksorts them; * and prints them to standard output in ascending order. * Shuffles the array and then prints the strings again to * standard output, but this time, using the select method. * * @param args the command-line arguments */ public static void main(String[] args) { String[] a = StdIn.readAllStrings(); Quick.sort(a); show(a); assert isSorted(a); // shuffle StdRandom.shuffle(a); // display results again using select StdOut.println(); for (int i = 0; i < a.length; i++) { String ith = (String) Quick.select(a, i); StdOut.println(ith); } }
/** * Reads in a sequence of extended ASCII strings or non-negative ints from standard input; * American flag sorts them; * and prints them to standard output in ascending order. * * @param args the command-line arguments: "int" to read input as non-negative integers */ public static void main(String[] args) { if (args.length > 0 && args[0].equals("int")) { int[] a = StdIn.readAllInts(); sort(a); // print results for (int i = 0; i < a.length; i++) StdOut.println(a[i]); } else { String[] a = StdIn.readAllStrings(); sort(a); // print results for (int i = 0; i < a.length; i++) StdOut.println(a[i]); } }
/**/ public static void main(string[] strarr) { string text = java.lang.String.instancehelper_replaceAll(StdIn.readAll(), "\\s+", " "); SuffixArray suffixArray = new SuffixArray(text); int num = suffixArray.length(); string text2 = ""; for (int i = 1; i < num; i++) { int num2 = suffixArray.lcp(i); if (num2 > java.lang.String.instancehelper_length(text2)) { text2 = java.lang.String.instancehelper_substring(text, suffixArray.index(i), suffixArray.index(i) + num2); } } StdOut.println(new StringBuilder().append("'").append(text2).append("'").toString()); } } public class LSD { //[Modifiers(Modifiers.Static | Modifiers.Final | Modifiers.Synthetic)] internal static bool s_assertionsDisabled; public static void sort(string[] strarr, int i) { int num = strarr.Length; int num2 = 256; string[] array = new string[num]; for (int j = i - 1; j >= 0; j += -1) { int[] array2 = new int[num2 + 1]; for (int k = 0; k < num; k++) { int[] arg_3D_0 = array2; int num3 = (int)(java.lang.String.instancehelper_charAt(strarr[k], j) + '\u0001'); int[] array3 = arg_3D_0; array3[num3]++; } for (int k = 0; k < num2; k++) { int[] arg_63_0 = array2; int num3 = k + 1; int[] array3 = arg_63_0; array3[num3] += array2[k]; } for (int k = 0; k < num; k++) { string[] arg_B4_0 = array; int[] arg_94_0 = array2; int num3 = (int)java.lang.String.instancehelper_charAt(strarr[k], j); int[] array3 = arg_94_0; int[] arg_A3_0 = array3; int arg_A1_0 = num3; num3 = array3[num3]; int num4 = arg_A1_0; array3 = arg_A3_0; int arg_B4_1 = num3; array3[num4] = num3 + 1; arg_B4_0[arg_B4_1] = strarr[k]; } for (int k = 0; k < num; k++) { strarr[k] = array[k]; } } } public LSD() { } /**/ public static void main(string[] strarr) { string[] array = StdIn.readAllStrings(); int num = array.Length; int num2 = java.lang.String.instancehelper_length(array[0]); for (int i = 0; i < num; i++) { if (!LSD.s_assertionsDisabled && java.lang.String.instancehelper_length(array[i]) != num2) { object arg_34_0 = "Strings must have fixed length"; throw new AssertionError(arg_34_0); } } LSD.sort(array, num2); for (int i = 0; i < num; i++) { StdOut.println(array[i]); } }
/** * Reads in a sequence of strings from standard input; heapsorts them; * and prints them to standard output in ascending order. * * @param args the command-line arguments */ public static void main(String[] args) { String[] a = StdIn.readAllStrings(); Heap.sort(a); show(a); }
/** * Reads in a sequence of strings from standard input; quicksorts them * (using an optimized version of 2-way quicksort); * and prints them to standard output in ascending order. * * @param args the command-line arguments */ public static void main(String[] args) { String[] a = StdIn.readAllStrings(); QuickX.sort(a); assert isSorted(a); show(a); }
/** * Reads in a sequence of strings from standard input; insertion sorts them; * and prints them to standard output in ascending order. * * @param args the command-line arguments */ public static void main(String[] args) { String[] a = StdIn.readAllStrings(); InsertionX.sort(a); show(a); }