Practice Question 1
Implement a variation of MSD radix sort with the following specifications:
- The function signature should be:
void radixMSD_string(char ** items, int length)
This function takes as input an array of strings, and sorts them using MSD radix sort. A string A is considered to be less than or equal to string B if and only if strcmp(A, B) <= 0.
Note that you should not be using strcmp(A, B) in your solution for this task.
Practice Question 2
Implement a variation of quicksort with the following specifications:
- The function signature should be:
void quicksort_string(char ** items, int length)
This function takes as input an array of strings, and sorts them using quicksort. A string A is considered to be less than or equal to string B if and only if strcmp(A, B) <= 0. You are free to use strcmp(A, B) in your solution for this task.
Practice Question 3
Compare the performance of radixMSD_string the performance of quicksort_string, by running both versions on omega, on an array of strings, that contains 10 million random strings, in random order. The length of each string should be randomly selected between 5 and 30 characters.
Practice Question 4
(This is Problem 10.1 from the textbook).
How many digits are there when a 32-bit quantity is viewed as a radix-256 number? Describe how to extract each of the digits. Answer the same question for radix 216.
Practice Question 4
(This is Problem 10.2 from the textbook).
For N = 103, 106, and 109, give the smallest radix that allows any number between 0 and N to be represented with four digits.
Practice Question 5
(This is Problem 10.3 from the textbook).
Implement a comparison function less
using the digit abstraction (so that, for example, we could run empirical studies comparing the algorithms in Chapters 6 and 9 with the methods in this chapter, using the same data).
Practice Question 6
(This is Problem 10.4 from the textbook).
Design and carry out an experiment to compare the cost of extracting digits using bit-shifting and
arithmetic operations on your machine. How many digits can you extract per second, using each of the
two methods?
Back to the list of assignments.