Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java, Please implement the way the interface specifies. Part A:Radix Sort Implem

ID: 3767726 • Letter: J

Question

Java, Please implement the way the interface specifies.

Part A:Radix Sort Implement a radix sort as described in the last section of Chapter 7 in your text. It should handle variable amounts of data and variable numbers of digits in the key values. Use testing to ensure radix sort works for at least three examples of different input sizes and various max digit length.

I need to implement the radix sort using the below java interface.

/**
* <h1><LeastSignificantDigit Radix Sort</h1>
* Each integer is first figuratively dropped into one level of buckets corresponding to the value of the rightmost digit.
* Each bucket preserves the original order of the integers as the integers are dropped into the bucket.
* There is a one-to-one relationship between the buckets and the values, represented by the rightmost digit.
* Then, the process repeats with the next significant digit until there are no more digits to process.
* In other words:
* -Take the least significant digit (or group of bits, both being examples of radices) of each integer.
* -Group the integers based on that digit, but otherwise keep the original order of integers.
* -Repeat the grouping process with each more significant digit.
* -Hybridizing the final steps can improve performance (but is not needed for this assignment)
*
*
*/
public interface RadixSort {

/**
* This method should re-initialize your RadixSort, clearing all data structures and resetting variables
*/
void init();

/**
* Run a full RadixSort (LSD variant) on the input int array.
* The array should be modified so that no return is needed.
*
* @param input int array for sorting, modify this input array
* @param max_significant_digits the maximum amount of digits in any given input in the array
*/
void sortRadixLSD(int[] input, int max_significant_digits);

/**
* Run a single pass of RadixSort, allowing us to step through the process.
* Checks to the input array after each sorting pass should show increasingly semi-sorted data.
* @param input the input array (no max_significant_digit is needed as we manually loop).
*/
void sortRadixLSDOnePass(int[] input);
}

Explanation / Answer

import java.io.*;

import java.util.*;

public interface RadixSort

{

void init();

void sort RadixLSD(int in[],int max_sig_digits();

}

public class RSort

{

public static void main(String args[])throws Exception

{

void init();{}

void sort RadixLSD(int in[],int max_sig_digits)

{

int n, a[],i;

System.out.println(“ /n Enter no.of digits”);

a[]= new int[n];

System.out.println(“ /n Enter Digits:”);

for(i=0;i<=n;i++)

a[i]=a[n];

}

void sortRadixLSD(int a[]);

System.out.println(“ /n The Sorted List”);

for(i=0;i<n;i++)

System.out.println(a[i] + “ “);

System.out.println(“ ”);

}

public void sortRadixLSD(int a[])

{

int m=a[0],n=a[].length,i,k=1,b[20], count[20];

for(i=0;i<n;i++)

{

if(a[i]>m)

m=a[i];}

}

for(i=0;i<n;i++)

count[(a[i]/k) %10] ++;

for(i=0;i<=10;i++)

count[i] += count[i-1];

for(i=0;i<=n-1;i++)

b[++count{(a[i]/k)%10]]=a[i];

for(i=0;i<n;i++)

a[i]=b[i];

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote