lab/lab13/RadixSort.java
private static String[] sortHelperLSD(String[] asciis, int index) {
        // Optional LSD helper method for required LSD radix sort
        // TODO: Implement LSD Sort
        // TODO: sort Strings => pad them on the right with empty values.
        // TODO: Make sure the method is NON-destructive (the original list cannot be modified).

        // buckets for inserting number of "digits"
        int[] buckets = new int[R];
        String[] sorted = new String[asciis.length];

        // counting process
        for (String a : asciis) {
            int pos = (int) a.charAt(a.length() - index - 1);
            buckets[pos] += 1;
        }


        // adjust buckets number
        int prev = 0;
        for (int i = 0; i < R; i++) {
            if (buckets[i] > 0) {
                buckets[i] += prev;
                prev = buckets[i];
            }
        }


        // re-order the asciis array in sorted array
        for (int numString = asciis.length - 1; numString >= 0; numString -= 1) {
            // int number of character at particular position
            int num = (int) asciis[numString].charAt(asciis[numString].length() - index - 1);

            // index of that String in sorted array
            buckets[num] -= 1;
            int pos = buckets[num];

            // move that String to the new array
            sorted[pos] = asciis[numString];

        }

        return sorted;

    }
/**
     * LSD helper method that performs a destructive counting sort the array of
     * Strings based off characters at a specific index.
     * @param asciis Input array of Strings
     * @param index The position to sort the Strings on.
     */
LSD helper method that performs a destructive counting sort the array of
Strings based off characters at a specific index.
@param asciis Input array of Strings
@param index The position to sort the Strings on.
LSD helper method that performs a destructive counting sort the array of Strings based off characters at a specific index . @param asciis Input array of Strings @param index The position to sort the Strings on .
private static String[] sortHelperLSD(String[] asciis, int index) {
        int[] buckets = new int[R];
        String[] sorted = new String[asciis.length];
        for (String a : asciis) {
            int pos = (int) a.charAt(a.length() - index - 1);
            buckets[pos] += 1;
        }
        int prev = 0;
        for (int i = 0; i < R; i++) {
            if (buckets[i] > 0) {
                buckets[i] += prev;
                prev = buckets[i];
            }
        }
        for (int numString = asciis.length - 1; numString >= 0; numString -= 1) {
            int num = (int) asciis[numString].charAt(asciis[numString].length() - index - 1);
            buckets[num] -= 1;
            int pos = buckets[num];
            sorted[pos] = asciis[numString];
        }
        return sorted;
    }
private static String [ ] sortHelperLSD ( String [ ] asciis , int index ) { int [ ] buckets = new int [ R ] ; String [ ] sorted = new String [ asciis . length ] ; for ( String a : asciis ) { int pos = ( int ) a . charAt ( a . length ( ) - index - 1 ) ; buckets [ pos ] += 1 ; } int prev = 0 ; for ( int i = 0 ; i < R ; i ++ ) { if ( buckets [ i ] > 0 ) { buckets [ i ] += prev ; prev = buckets [ i ] ; } } for ( int numString = asciis . length - 1 ; numString >= 0 ; numString -= 1 ) { int num = ( int ) asciis [ numString ] . charAt ( asciis [ numString ] . length ( ) - index - 1 ) ; buckets [ num ] -= 1 ; int pos = buckets [ num ] ; sorted [ pos ] = asciis [ numString ] ; } return sorted ; }
LSD helper method that performs a destructive counting sort the array of
 Strings based off characters at a specific index.
LSD helper method that performs a destructive counting sort the array of Strings based off characters at a specific index .
// Optional LSD helper method for required LSD radix sort // TODO: Implement LSD Sort // TODO: sort Strings => pad them on the right with empty values. // TODO: Make sure the method is NON-destructive (the original list cannot be modified). // buckets for inserting number of "digits" // counting process // adjust buckets number // re-order the asciis array in sorted array // int number of character at particular position // index of that String in sorted array // move that String to the new array