{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# HW1v1.2 - ECE 242 HOMEWORK 1 1 Fall 2009(25 Points What is...

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

ECE 242 – HOMEWORK 1 Fall 2009 1. (25 Points) What is the asymptotic complexity of the following methods, in terms of the Big- O notation a. Int methodOne(int n) { for (int i=1; i<n; i*2) { System.out.println(i); } } b. Int methodTwo(int n) { Count =1; for (int i=n; i<=n; i= i*2){ while(count < n){ System.out.println(i); Count *= 2; } } } c. Int methodThree(int n) { for(int i=1; i<n; i=i+2){ for(int j=0; j<2n; j=j+2){ System.out.println(j); } } } d. Int methodFour(int n) { for(int i=0; i<n; i++){ for(int j=0;j<i;j++){ printSum(n); } } } printSum(int n){

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

View Full Document
int sum=0; for(int i=0; i<n;i++){ sum+=i; } } e. Int methodFive(int n){ if(n>1000){ for(int i=0;i<n;i++){ System.out.println(i); } } else{ for(int j=0; j<n;j=j*2){ System.out.println(j); } } } 2. (15 Points) The table below shows the growth function of different algorithms, what is the asymptotic complexity of each algorithm. These algorithms are executed on a processor which can execute 100 instructions in a millisecond, sort the algorithms according to their
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 3

HW1v1.2 - ECE 242 HOMEWORK 1 1 Fall 2009(25 Points What is...

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

View Full Document
Ask a homework question - tutors are online