In this assignment, you are asked to write a program that gets a series of string chars separated by space and followed by EOF from the user through standard input, alphabetically sorts them using bucket sort, and prints the sorted strings out on the console.
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 sorted individually. To sort each bucket in this assignment, you will use the insertion sort algorithm. Also, to compare strings with one another, you need to use the function strcasecmp from the string.h library as this sorting machine is not case-sensitive.
Figure 1: Example of bucket sort for sorting numbers 29, 25, 3, 49, 9, 37, 21, 43. Numbers are distributed among bins (left image). Then, elements are sorted within each bin (right image).
Bucket Sort's Data Structure
In order to implement the bucket sort algorithm for strings, you need to have an array of buckets such that the bucket is a C structure defined in the following way:
struct bucket{
char* min_word;
struct node* head;
};