t1 - 3.1 m = m a return m End Exp2 a,n Assumption n is an...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CS3230 Tutorial 1 1. Consider the following functions. n n n log n n 2 + 60 n + 5 7 n 2 + 3 log n log log n 2 n n 12 (log n ) 2 4 n ( 5 2 ) n 2 n ( 1 2 ) n n ! n log n 2 12 log n 2 log log n + 15 n 2 + log n ln n (a) Group these functions so that f ( n ) and g ( n ) are in the same group iff f ( n ) = Θ( g ( n )). (b) Order the groups found in part (a) on the basis of increasing order, from smallest to the largest. 2. In the following, state your answer and prove it. (a) Is 3 n +1 = O (3 n )? (b) Is (4 n ) 2 = O ((2 n ) 2 )? (c) Is 3 n = O (2 n )? (d) Is 2 2 log n = O ( n )? 3. Show that n i =1 1 i = O (log n ). 4. Give asymptotic tight bound for T ( n ) given by T ( n ) = T ( b n/ 3 c ) + T ( b 2 n/ 3 c ) + 6 n 2 , for n 3. T (1) = 10, T (2) = 100. 5. Suppose lim n →∞ f ( n ) g ( n ) = c . Then show that, (a) If c = 0, then f ( n ) = O ( g ( n )), but f ( n ) 6 = Ω( g ( n )). (b) If c = , then f ( n ) = Ω( g ( n )), but f ( n ) 6 = O ( g ( n )). (c) If 0 < c < , then f ( n ) = Θ( g ( n )). 6. Consider the following algorithms to compute a n . Exp1( a,n ) Assumption: n is an integer 0, and a 1 1. If n = 0, then return 1 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
2. m = 1 3. For k = 1 to n do
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { 3.1. m = m * a } return m End Exp2( a,n ) Assumption: n is an integer ≥ 0, and a ≥ 1 1. If n = 0, then return 1 2. Else, return a * Exp 2( a,n-1) End Exp3( a,n ) Assumption: n is an integer ≥ 0, and a ≥ 1 1. If n = 0, then return 1 2. Else 2.1. Let m = b n 2 c 2.2. Let x = Exp 3( a,m ) 2.3. Let y = x * x 2.4. If n is even, then return y 2.5. Else, return y * a End (a) Assume constant time complexities for basic operations (multiplication, addition, etc). Give the time complexities for the above two alogrithms in terms of n (in big O notation). (b) You may want to implement the above algorithms and see the running time of the algorithms for various values of n . 2...
View Full Document

{[ snackBarMessage ]}

Page1 / 2

t1 - 3.1 m = m a return m End Exp2 a,n Assumption n is an...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online