Problem: Sorting Algorithms
Objective: Comparison of Merge Sort and Quicksort
Task 1: Implementation
- You have to implement Merge Sort and Quicksort
- You are given a cpp file sortarray.cpp
- Generate arrays in ascending, descending and random order.
- Populate the array of size n by generating random integers
- Apply merge sort and quicksort to sort the array
- Record the time to accomplish each sorting
- Finally print the array
- Each generation process should generate an entirely new array
- Your implementation must be memory efficient
Task 2: Statistics generation
- Create another file statistics.cpp
- Vary array size from 10 to 1000000. You can increase the upper range if that
gives you better statistics.
- Generate in ascending, descending and random order, sort them by merge sort
and quick sort and record the timing in the following table.
- For example: You want to get timing for n=10, ascending with merge sorting.
Generate the scenario multiple times and take the average sorting time. Record
only the average sorting time into the cell.
- Plot running time of both the sorting algorithm against the input array size n for
best, worst and average case.
n=
Case Sort
merge quick merge quick merge quick
10
100
1000
10000
100000
1000000
ascendi ng
descend ing
random
Note:
1. Code in C++
2. You have to submit the codes and a report containing complexity analysis, machine configuration, table and plots
Submission
- Create an empty folder named to your student_id (e.g. 1705001)
- Put all the source code (.cpp) files and reports in that folder
- Zip that folder. It should give you student_id.zip
- Submit the zip file to moodle
Online
- ● Prepare to sit for an online.
- ● You must look up and practice relevant problems before attending online


