2011Winter2009_Assignment1

# 2011Winter2009_Assignment1 - Department of Computer Science...

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

1 Department of Computer Science and Engineering York University, Winter 2009 CSE 2011: Assignment 1 Due Date - Monday, April 13, by Noon ! Question 1 Algorithm Design [10 points] Assume an arbitrary set of n distinct numbers ( S ) distributed over an interval [0,N], n<<N. Devise an algorithm for outputting k smallest elements of S in order , where k<n. (Note: k is NOT a constant, but an easily computable function of n.) The number of ‘compare’ (comparison between two elements) operations in your algorithm should be O(n*log(k)) or better. The space requirements should not exceed O(n) 1 , and only the use of linear data structures is allowed. Give a pseudo-code description of your algorithm, and briefly justify its overall running time and the number of compare operations. Question 2 Big-O Analysis [10 points] (a) Express the running time of the following program segment using big- θ notation. int k=1, sum=0; for (int i=0; i<n; i++) { k=2*k; } for (int j=k; j>1; j=j/3) { sum++; } (b) Consider recursive method Enigma, as given below. int Enigma(int num) {

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

2011Winter2009_Assignment1 - Department of Computer Science...

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

View Full Document
Ask a homework question - tutors are online