Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have some of the code already done as provided at the end. Need the bonus part of the question answered as soon as possible.

I have some of the code already done as provided at the end. Need the bonus part of the question answered as soon as possible. Also feel free to change anything in the code provided as you see fit. Please and thank you. Will give an upvote.

image text in transcribed

image text in transcribed

image text in transcribed

The code I have so far:

public static void sort(String[] array) { if (array.length == 0) return; // Checking if string is empty or not // Determining length of our input string int max = 0; for (int i = 1; i > buckets = new HashMap>(bucketCount); // creating the buckets char a = 'a'; for (int i = 0; i ()); } // assign array values into buckets for (int i = 0; i  bucket = buckets.get(key); // do an insertion sort on bucket for (int i = 1; i = 0 && bucket.get(j).compareToIgnoreCase(temp) > 0; j--){ // to "insert", we need to add and remove bucket.add(j+1, bucket.get(j)); bucket.remove(j); } // place the saved value in the proper location bucket.add(j+1, temp); } // pile the current bucket back into array for (int j = 0; j   In this assignment, you are asked to write a program that reads a series of strings sepa- rated with comma from a given file. Your program nceds to alphabetically sort the strings using bucket sort and write the result in the output file. The strings in the output must be separated with comma. The names and addresses of input and output files are given by the user through console at the beginning of the program. 1 Bucket Sort Bucket sort, or bin sort, is a sorting algorithm that works by distributing the elements into a number of buckets. Each bucket is then sorted individually. To sort each bucket in this assignment, you need to use the sort() method in java ntil.Arrays class. 29 25 3 49 9 37 21 43 0-9 10-19 20-29 30-39 40-49 43 37 49 25 37 49 21 29 43 -9 10-19 20-29 30-39 40-49 3 9 21 25 29 37 43 49 Figure 1: Example of bucket sort for sorting mimbers 29, 25, 3, 49, 9, 37, 21, 13. Numbers are distributed among bins (left image). Then, clements are sorted within cach bin (right image)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Oracle8I Building Efficient Databases

Authors: Jonathan Lewis

1st Edition

0201715848, 978-0201715842

More Books

Students also viewed these Databases questions