Data Structures & Alogs HW_Part_5

Data Structures & Alogs HW_Part_5 - 3 Algorithm...

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

View Full Document Right Arrow Icon
3 Algorithm Analysis 3.1 Note that n is a positive integer. 5 n log n is most ef f cient for n =1 . 2 n is most ef f cient when 2 n 4 . 10 n is most ef f cient for all n> 5 . 20 n and 2 n are never more ef f cient than the other choices. 3.2 Both log 3 n and log 2 n will have value 0 when n . Otherwise, 2 is the most ef f cient expression for all 1 . 3.3 2 log 3 n log 2 nn 2 / 3 20 n 4 n 2 3 n n ! . 3.4 (a) n +6 inputs (an additive amount, independent of n ). (b) 8 n inputs (a multiplicative factor). (c) 64 n inputs. 3.5 100 n . 10 n . About 4 . 6 n (actually, 3 100 n ). n . 3.6 (a) These questions are quite hard. If f ( n )=2 n = x , then f (2 n 2 n = (2 n ) 2 = x 2 . (b) The answer is 2 ( n log 2 3 ) . Extending from part (a), we need some way to make the growth rate even higher. In particular, we seek some way to make the exponent go up by a factor of 3. Note that, if f ( n )= n log 2 3 = y , then f (2 n log 2 3 n log 2 3 =3 x . So, we combine this observation with part (a) to get the desired answer. 3.7 First, we need to f nd constants c and n o such that 1 c × 1 for n>n 0 . This is true for any positive value c< 1 and any positive value of n 0 (since n plays no role in the equation). Next, we need to f nd constants c and n 0 such that 1 c × n for 0 . This is true for, say, c and n 0 . 17
Background image of page 1

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

View Full DocumentRight Arrow Icon
18 Chap. 3 Algorithm Analysis 3.8 Other values for n 0 and c are possible than what is given here. (a) The upper bound is O( n ) for n 0 > 0 and c = c 1 . The lower bound is Ω( n ) for n 0 > 0 and c = c 1 . (b) The upper bound is O( n 3 ) for n 0 >c 3 and c = c 2 +1 . The lower bound is Ω( n 3 ) for n 0 3 and c = c 2 . (c) The upper bound is O( n log n ) for n 0 5 and c = c 4 . The lower bound is Ω( n log n ) for n 0 5 and c = c 4 .
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 10/31/2011 for the course BCN 3431 at University of Florida.

Page1 / 4

Data Structures &amp; Alogs HW_Part_5 - 3 Algorithm...

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

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