CS60 Homework Assignment 5 ------------------------------ Due: Wed. Oct 8th at 1:00pm In this assignment, the task is to write an in place string sorting function in C. The strings are to be sorted according to string length (see the 'strlen()' function) from shortest to longest. Strings of the same size are considered equal and can appear in any order in the final sorted list. The file 'hw5.c' on the website contains the template code for this homework assignment with a comment indicating where your function should be called. It must be used for this homework and the main() function code cannot be modified beyond replacing the comments with your sort function call. ------------BEGIN CODE---------------------- #include #include #include "hw5data.h" main() { int i; printf("\nMonths\n-----------\n"); for (i=0; i<12; i++) { printf("%d: %s\n", i, months[i]); } // your sort function goes here printf("\nMonths Sorted\n-----------\n"); for (i=0; i<12; i++) { printf("%d: %s\n", i, months[i]); } printf("\nDays\n-----------\n"); for (i=0; i<7; i++) { printf("%d: %s\n", i, days[i]); } // your sort function goes here printf("\nDays Sorted\n-----------\n"); for (i=0; i<7; i++) { printf("%d: %s\n", i, days[i]); } } --------------END CODE--------------------- This template is not given for convenience, but instead to insure that it is understood how the desired function should perform. Note that the same process is run on the same array before and after the sort function is called, indicating that the strings are being sorted 'in place' by the sort function. Also note that you must write one sort function that can sort different sized lists of strings. You may use any sorting algorithm you like to implement the string sorting. HINT: algorithms to look up: insertion sort, quicksort. Turnin ------------------------- The turnin tag for this homework is 'hw5' and must include the code, a script file showing compilation and execution and an optional README file. Sample Output -------------------------- [root@localhost hw5]# ./a.out Months ----------- 0: January 1: February 2: March 3: April 4: May 5: June 6: July 7: August 8: September 9: October 10: November 11: December Months Sorted ----------- 0: May 1: June 2: July 3: March 4: April 5: August 6: January 7: October 8: February 9: November 10: December 11: September Days ----------- 0: Sunday 1: Monday 2: Tuesday 3: Wednesday 4: Thursday 5: Friday 6: Saturday Days Sorted ----------- 0: Sunday 1: Monday 2: Friday 3: Tuesday 4: Thursday 5: Saturday 6: Wednesday [root@localhost hw5]#