Question: Write a program in PYTHON 3 that does the following: Generates random strings ofstring length m at random in between 1 and max ( 1

Write a program in PYTHON 3 that does the following:

  1. Generates random strings ofstring lengthmat random in between 1 andmax(1<=m<=max). The lengthmis stored as a variable that can be changed. The function then allocatesm + 1characters. The firstmcharacters (0......m-1) are chosen at random in between the characters "a"and "z". Them-th character is set to 0 in order to mark the end of the string.
  2. Develop a counting sort algorithm for strings that sorts a given array of strings according to the character at position d. A non-existing digit d is treated as a 0 throughout the counting sort.
  3. Use this new counting sort algorithm to implement radix sort for an array of strings. Create a timer function that measures the runtime performance forarrays of randomstrings 5 times for every combination of array size n = 50000; 100000; 500000; 750000 and length of the random strings m = 25; 35; 45.

Notes:

  • Do not copy the characters itself, but only the pointer to the string/array of characters instead.
  • Do not fill the strings with 0's to make them of equal size.
  • If you move a string within the array of strings then you must update the array containing the length of the strings accordingly.
  • When moving the string into its correct position you also have to move the length of the string into its correct position.
  • You can use am int to store the counters/positions.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!