# hw1_sol - Homework 1 Solutions CSCI-2300 Data Structures...

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

Homework 1 Solutions CSCI-2300: Data Structures and Algorithms Spring 2007 1. 2.1) Order the following functions by growth rate: N , N , N 1 . 5 , N 2 , N log N , N log log N , N log 2 N , N log( N 2 ), 2 /N , 2 N , 2 N/ 2 , 37, N 2 log N , N 3 . Indicate which functions grow at the same rate. Solution: 2 /N , 37, N , N , N log log N , N log N , N log( N 2 ), N log 2 N , N 1 . 5 , N 2 , N 2 log N , N 3 , 2 N/ 2 , 2 N . N log N and N log( N 2 ) grow at the same rate. 2. 2.2) Suppose T 1 ( N ) = O ( f ( N )) and T 2 ( N ) = O ( f ( N )). Which of the following are true? (a) T 1 ( N ) + T 2 ( N ) = O ( f ( N )) (b) T 1 ( N ) T 2 ( N ) = O (1) (c) T 1 ( N ) = O ( T 2 ( N )) Solution: (a) True. (b) False. A counterexample is T 1 ( N ) = N 2 , T 2 ( N ) = N , and f ( N ) = N 2 . (c) False. The same counterexample applies. 3. 2.7) For each of the following six program fragments: (a) Give an analysis of the running time (Big-Oh will do). (b) Implement the code in the language of your choice, and give the running time for several values of N (c) Compare your analysis with the actual running times

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

View Full Document
2
Answer: (a) i. The running time is

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.

## This note was uploaded on 04/07/2008 for the course DATA STRUC 2400 taught by Professor Das during the Spring '08 term at Rensselaer Polytechnic Institute.

### Page1 / 5

hw1_sol - Homework 1 Solutions CSCI-2300 Data Structures...

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

View Full Document
Ask a homework question - tutors are online