Assignment-02 Solution

$30.00 $24.00

Implement Shellsort which reverts to insertion sort. (Use the increment sequence 7, 3, 1). Create a table (or preferably, a plot) for the total number of comparisons made in the sorting the data for both cases (insertion sort phase and shell sort phase). Explain why Shellshort is more effective than Insertion sort in this case.…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Description

5/5 – (2 votes)
  1. Implement Shellsort which reverts to insertion sort. (Use the increment sequence 7, 3, 1). Create a table (or preferably, a plot) for the total number of comparisons made in the sorting the data for both cases (insertion sort phase and shell sort phase). Explain why Shellshort is more effective than Insertion sort in this case.

  1. The Kendall Tau distance is a variant of the “number of inversions” we discussed in class. It is defined as the number of pairs that are in different order in two permutations. Write an efficient program that computes the Kendall Tau distance in less than quadratic time on average. Plot your results and discuss. Use the dataset provided here. Note: data0.* for convenience is an ordered set of numbers (in powers of two). data1.* are shuffled data sets of sizes (as given by “*”).

  1. Create a data set of 8192 entries which has in the following order: 1024 repeats of 1, 2048 repeats of 11, 4096 repeats of 111 and 1024 repeats of 1111. Write a sort algorithm that you think will sort this set “most” effectively. Explain why you think so.

  1. Implement the two versions of MergeSort that we discussed in class. Create a table or a plot for the total number of comparisons to sort the data (using data set here) for both cases. Explain.

Data Set for Questions above:

https://drive.google.com/file/d/0B4xMi5S-VFVRVWh0YzV6bmFLMjQ/view?usp=sharing

5. Implement Quicksort using median-of-three to determine the partition

element. Compare the performance of Quicksort with the Mergesort implementation and dataset from Q4. Is there any noticeable difference when you use N=7 as the cut-off to insertion sort. Experiment if there is any value of “cut-off to insertion” at which the performance inverts.

Assignment-02 Solution
$30.00 $24.00