{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

hw1_sol

# hw1_sol - CSC 316 Data Structures Homework 1 Solution...

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

CSC 316 Data Structures Homework 1 Solution —– Provided by: Hui Wang 1. (a) n 2 = O ( n 2 + 1) Take c=1, n 0 = 1, then for any n n 0 , n 2 c · ( n 2 + 1). By definition, we have n 2 = O ( n 2 + 1). (b) n 2 = O (2 n 2 ) Take c=1, n 0 = 1, then for any n n 0 , n 2 c · (2 n 2 ). By definition, we have n 2 = O (2 n 2 ). (c) n i =1 i k = O ( n k +1 ) n i =1 i k n i =1 n k , since i n , for n 1. Take c=1, n 0 = 1. (d) n 2 = Θ( n 2 - 1) First show n 2 = O ( n 2 - 1), then show n 2 = Ω( n 2 - 1). Take c=2, n 0 = 1, then for any n n 0 , n 2 2 · ( n 2 - 1). Thus n 2 = O ( n 2 - 1). Take c=1, n 0 = 1, then for any n n 0 , n 2 1 · ( n 2 - 1). Thus, n 2 = Ω( n 2 - 1). (e) n 2 = Ω( n 2 - 1) when n 1 Please see the proof in the second part in d). 2. (a) f ( n ) = O ( g ( n )) implies g ( n ) = O ( f ( n )) False. Counter example: f ( n ) = n and g ( n ) = n 2 . (b) f ( n ) = O ( g ( n )) implies 2 f ( n ) = O (2 g ( n ) ) False. Counter example: f ( n ) = n and g ( n ) = n 2 . (c) f ( n ) = O (( f ( n )) 2 ) False. Counter example: f ( n ) = 1 n . (d) f ( n ) = O ( g ( n )) implies g ( n ) = Ω( f ( n )) True. (e) f ( n ) = Θ( f ( n/ 2)) False. Counter example: f ( n ) = 2 n , then f ( n/ 2) = 2 n/ 2 .

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 3

hw1_sol - CSC 316 Data Structures Homework 1 Solution...

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

View Full Document
Ask a homework question - tutors are online