[Solved] CH08-320201-Homework 1 Asymptotic Analysis and Selection Sort

$25

File Name: CH08-320201-Homework_1_Asymptotic_Analysis_and_Selection_Sort.zip
File Size: 574.62 KB

SKU: [Solved] CH08-320201-Homework 1 Asymptotic Analysis and Selection Sort Category: Tag:
5/5 - (1 vote)

Problem 1: Asymptotic Analysis

Considering the following pairs of functions f and g, show for each pair whether f (g), f O(g), f o(g), f (g), f (g), g (f), gO(f), go(f), g (f), or g(f).

  • f(n) = 3n and g(n) = n3.
  • f(n) = 7n0.7 + 2n0.2 + 13logn and g(n) = n.
  • f(n) = n2/logn and g(n) = nlogn.
  • f(n) = (log(3n))3 and g(n) = 9logn.

Problem 2: Selection Sort

In class, we discussed Insertion Sort. Selection Sort is similar to Insertion Sort and works as follows. Given an array of elements, you always take the current element and exchange it with the smallest element that can be found on the right hand side of the current element. In doing so, you will gradually build up a sorted list on the left side (just as in Insertion Sort), and in each iteration attach the smallest element from the remaining unsorted right side to it.

  • Implement Selection Sort.
  • Show that Selection Sort is correct (consider the loop invariant).
  • Generate random input sequences of length n as well as sequences of length n that represent the worst case and the best case for the Selection Sort algorithm. Briefly describe how you generated the sequences (e.g. programmatically with a random sequence generator).
  • Run the algorithm on sequences of (c) with length n for increasing values of n and measure the computation times. Plot curves that show the computation time of the algorithm in the best, average, and worst case for increasing input length n. Note that in order to compute reliable measurements for the average case, you have to run the algorithm multiple times for each entry in your plot. You can use whatever plotting method you like (R, Matlab, Excel, by hand, ).
  • Interpret the plots in (d) with respect to asymptotic behavior and constants.

Reviews

There are no reviews yet.

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

Shopping Cart
[Solved] CH08-320201-Homework 1 Asymptotic Analysis and Selection Sort
$25