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

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

View Full Document Right Arrow Icon
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){
Background image of page 1

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

View Full DocumentRight Arrow Icon
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
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 note was uploaded on 02/20/2010 for the course ENGINEERIN 242 211 taught by Professor Tessier during the Spring '10 term at UMass (Amherst).

Page1 / 3

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

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