[Solved] CS590 homework 1 C++ & running times

$25

File Name: CS590_homework_1__C++_&_running_times.zip
File Size: 348.54 KB

SKU: [Solved] CS590 homework 1 – C++ & running times Category: Tag:
5/5 - (1 vote)

You are given an integer vector which is represented by int* an array of integers and its dimension m as aseparate parameter. We are interested in sorting arrays of integer vectors according to a pre-definednotion of vector length. You therefore are given the function ivector_length(v, m) that computes andreturns the length of vector v with dimension m asYou are given a naive (and very inefficient) implementation of insertion sort for arrays of integer vectors.Questions (100 points)1. Develop an improved implementation of insertion sort for integer vector (insertion_sort_im) thatprecomputes the length of each vector before the sorting. Keep in mind that the vectors are sortedaccording to their length (see ivector_length function). You can test the correctness of your sortingalgorithm using the provided check_sorted function.2. Implement a merge sort for an array of integer vectors. As for the improved insertion sort algorithm,you should precompute the length of the vectors before the sorting and the sorting is done according tothe vector length. Test the correctness of your merge sort implementation using the providedcheck_sorted function.3. Measure the runtime performance of insertion sort (naive and improved) and merge sort for random,sorted, and inverse sorted inputs of size n = 10000; 25000; 50000; 100000; 250000; 500000; 1000000;2500000 and vector dimension m = 10; 25; 50. You can use the provided functions create_random_ivector,create_sorted_ivector, create reverse_sorted_ivector.Repeat each test a number of times (usually at least 10 times) and compute the average running time foreach combination of algorithm, input, and size n. Report and comment on your results.Remarks: You might have to adjust the value for n depending on your computers speed, but allow each testto take up to a couple of minutes. Start with smaller values of n and m and stop if one instance of the algorithm takes more than 10min to complete (the insertion sort implementations will hit that limit early on). Report and comment means that you have to analyze and interpret your findings properly. Whatdo the experiments tell you? The programming, testing and the experimentation will take some time. Start early. Feel free to use the provided source code for your implementation. You have to document yourcode

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CS590 homework 1 C++ & running times
$25