Submit to Blackboard before the deadline. You will be able to revise your answers until the deadline with no penalty.
(Programming) Task 1 (40 pts.)
Implement a variation of radix sort (either MSD or LSD is fine) with the following specifications:
- The function signature should be:
void radixsort(int * items, int length, int radix)
- Radix can be any number between 2 and 100,000.
Note radix_sort.c contains a function radixMSD2(int * items, int length, int radix), which implements MSD radix sort but only works with a radix that is 2, 4, 16, 256, 65536, as well as an implementation of LSD radix sort for radix = 2. Feel free to reuse as much of that code as you find useful. Similarly, feel free to reuse as much of the textbook code as you find useful.
Submit your function in a program called task1.c.
(Programming) Task 2 (20 pts.)
Compare, for various radix values, the running time of your solution for task 1 with the performance of the version of quicksort defined by textbook programs 7.1 and 7.2, by running both versions on omega, on an array of integers, that contains 100 million integers in random order.
The values of the integers should be uniformly distributed between 0 and 2 billion. For your implementation of radix sort, you should test it using the following radix values:
For this task, you should submit two things:
- A C file, called task2.c, that you used to do the testing. You should use a single C file for the testing. Your executable should take a SINGLE commandline argument, that specifies which of the test cases is run:
- If the commandline argument is 0, it means running the test case with quicksort and 100 million integers in random order.
- If the commandline argument is N, and N != 0, it means running the test case with your implementation of MSD radix sort, using N as the radix, and 100 million integers in random order.
- In your answers document, report the running time that you observed for each of the five cases.
Task 3 (10 pts.)
Given the capabilities of modern computers, discuss whether it would it make sense to use MSD radix sort if we have to sort 100 million 64-bit positive integers, and each integer has a value between zero and 264-1. Discuss what choice you would make for the radix and why, so as to optimize performance.
Task 4 (15 pts.)
Suppose that we need to sort 100 million integers, whose values range from -1,000,000 to +1,000,000. Describe, in pseudocode, an algorithm based on the MSD radix sort algorithm that would be able to sort these numbers in linear time.
Task 5 (15 pts.)
Suppose that we need to sort 100 million real numbers (represented as numbers of type float in C), whose values are between -1 and 1. Describe, in pseudocode, an algorithm based on the MSD radix sort algorithm that would be able to sort these numbers in linear time, assuming that the values of the numbers are spread out relatively evenly within the [-1, 1] range. Explain why this assumption (that the numbers are spread out relatively evenly) is important for the performance of your algorithm.
How to submit
The assignment should be submitted via Blackboard.
Submit a ZIPPED directory called Firstname_Lastname.zip. No other forms of compression are accepted, contact the instructor or TA if you do not know how to produce .zip files. The zipped directory should contain the following documents:
- task1.c
- task2.c
- answers.xxx
As stated on the course syllabus, programs must be in C, and must run on omega.uta.edu.
IMPORTANT: Pay close attention to all specifications on this page, including
file names and submission format. Even in cases where your answers are correct,
points will be taken off liberally for non-compliance with the instructions given on this
page (such as wrong file names, wrong compression format for the submitted code,
and so on). The reason is that non-compliance with the instructions makes the
grading process significantly (and unnecessarily) more time consuming. Contact the
instructor or TA if you have any questions.
Back to the list of assignments.