# Programming Assignment

## Programming Assignment

This programming assignment is to implement the following three sorting algorithms and to collect time performance measurements on them.

1. Mergesort,

2. Heapsort,

3. Quicksort.

The running time of each sorting algorithm must be measured in two ways:

· Count the number of key comparisons, COMPCOUNT. To obtain this count, it is suggeted that you write a function COMPARE(X, Y ), which will perform a comparison between X and Y and increment COMPCOUNT. Then, wherever you need to perform a key comparison in your algorithms, you simply make a call to this function.

· Use the actual measured CLOCK time.

You need to carry out the experiment in two parts.

## 1 A small array size, n = 32, to verify correctness

Run each algorithm on three sets of data:

(1) Sorted; (2) Reversely sorted; and (3) Randomly generated.

For simplicity, you may use integers. For each case, make sure the same original data is input to all three algorithms. Print both the sorted array and measured number of comparisons for each case to show the correctness of your algorithms.

## 2 Large array sizes to determine time complexity

Run each sorting algorithm on the following array sizes:

· n = 210 = 1, 024

· n = 215 = 32, 768

· n = 220 = 1, 048, 576

For each value of n, produce an array of n randomly generated elements only once. (For simplicity, you may use integers.) Again, make sure you provide the same randomly-generated array of data to all three sorting algorithms.

Tabulate the performace results, listing both the number of comparisons and the measured clock times. Use the tabulated number of comparisons to determine the time complexity. For example, does the data for quicksort verify O(n2) or O(n log n) time, and what is the constant factor? Note that since you use a random sequence to sort, the running times should correspond to the average-case time complexities.

Pages (550 words)
Approximate price: -

Why Choose HelpHub

Quality Researched Papers

We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.

Qualified Writers

We have hired a team of professional writers experienced in academic and business writing. Most of them are native speakers and PhD holders able to take care of any assignment you need help with.

Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account.

On Time Delivery

All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. We will always strive to deliver on time.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text.

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

## Calculate the price of your order

Total price:
\$0.00

How it works?

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

HelpHub Writing Services

No need to work on essay at night. Sleep tight, we will cover your back. We offer all kinds of essay writing services.

## Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.