asg2 - a A =(1 1/n)^n B = 1 b A = n B = n c A = n^0.7 B =...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Assignment 2 COP 3530, Fall 2009 Due: 8 th Sep 2009 1. Assuming that the system clock has an error of 50 ms, estimate the average running time for worst case bubble sort for 10%, 5% and 1% accuracy (Reference: Lecture Notes 3). Run the bubble sort (Reference: on an integer array with 20 elements. 2. Present the algorithm you used in question 1 and count the number of comparison operations and steps. Present your counting. 3. Let O(g(n))= { f(n): there exist positive constants c and n 0 such that 0<=f(n)<=cg(n) for all n>=n 0 }. Indicate, for each pair of expressions (A, B), whether A is the Big O of B that means A=O(B). Assume that c is a constant and c>1.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: a) A = (1+1/n)^n , B = 1 b) A = n! , B = n! c) A = n^0.7 , B = n^(cos n) d) A = n B = (lg n)^c , for some c>0 e) A = n^lg c , B = c^lg n 4. Let A[1. .n] be an array of n distinct numbers. If i < j and A[i] > A[j], then the pair (i , j) is called an inversion of A. a) List the inversions of the array [4, 2, 1, 9, 3] b) What array with elements from the set {1,2,…,n} has the most inversions? Justify your answer. c) If the length of the input array is fixed, what is the relationship between the running time of insertion sort and the number of inversions in the input array? Justify your answer....
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online