COMP225 Practical Exercises

Week 4

In this practical you will learn more about implementing radix sort and bucket sort, and to test them experiementally with another sorting algorithm.

Download the file radix.cpp in which there is a function definition for radix sort. The file sorting.cpp contains a the implementation of mergesort on arrays and testRadix.cpp can be used for testing your functions.

  1. (*) Implement radixSort for an array. Assume that the input is for sorting binary integers (ie each number only has 0's or 1's). Your lecture notes should help.

  2. (*) Experimentally compare your implementation with another sorting function, for example mergeSort for an array. (Run your algorithm for a number of sizes of array. Do a similar test for another sorting algorithm. Plot the two graphs and add it to your portfolio; include a short explanation comparing the two graphs.)

    Submit your completed program file radix.cpp by Monday of Week 5 using the online submission system. Your file should only contain the functions you use for radixSort, and in particular should not contain any "int main() {...}" function. Use the provided file for testing your function.

  3. Implement bucketSort from lectures.

    Please note Your experiments will be marked later when you hand in your portfolio with your assignment.

    All enquiries to Annabelle McIver