Docsity

Algorithmic Complexity Assignment, Exercises of Data Structures and Algorithms

Partial preview of the text

Download Algorithmic Complexity Assignment and more Exercises Data Structures and Algorithms in PDF only on Docsity!

CS

Assignment 3 Due Date: Friday, September 25th at 11:59pm

  1. (10 points) Determine, for the typical algorithms that you use to perform calculations by hand, the running time to do the following (also explain the reasoning behind your answers) (a) Add two n-digit integers (b) Multiply two n-digit integers (c) Divide two n-digit integers.
  1. (15 points) If our machine takes 0.5ms to finish for input size of 100, how large a problem can be solved in 1 minute if the running time is the following? (a) O(n) (b) O(n log n) (c) O(n^2 ) (d) O(n^3 )
  1. (15 points) Rearrange the following functions from smallest asymptotic growth rate to the largest asymp- totic growth, if any functions have the same asymptotic growth rate, please indicate that (use < to denote the function on the right has a larger growth rate and use = to denote same growth rate, for example n < n^2 and 3n = 4n)

n

n, 264 , n log 2 n − 4 n + 12, 2 n, 17 n^1.^5 − 5000 n, 4000 log n +

13 n^2 n

, n

n + n log 4 n

  1. (15 points) Perform insertion sort on the following list, show the steps of the inner loop and show when an iteration of the outer loop finishes. 10 , 5 , 8 , 2 , 9 , 1
  1. (15 points) Perform quicksort on the following list, show the pivot and show how the left and right pointers are moving and how the elements are swapped after in each step, choose the leftmost element of each sublist as the pivot.