Chapter3ProblemsSol - UML CS Analysis of Algorithms 91.404

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

View Full Document Right Arrow Icon
UML CS Analysis of Algorithms 91.404 Spring, 2001 Prepared by TA Wenhua (Michelle) Shi          Assigned: Friday, 2/2 Due: Friday, 2/9 (start  of lecture) This assignment covers textbook material in Chapters1-2. Note: Partial credit for wrong answers is only given if work is shown. 1. (10 points) Let R be a problem. Suppose that the worst-case asymptotic time complexity of R is in O(n 2 ) and also in (n lg n) . Now, let A be an algorithm that solves R . Which of the following statements about A are consistent with this information about the asymptotic time complexity of R ? ( Note: The answer might include more than one of the choices .) A has worst-case time complexity O(n 2 ) . A has worst-case time complexity O(n 3/2 ) . A has worst-case time complexity O(n) . A has worst-case time complexity Θ ( n 2 ) . A has worst-case time complexity Θ ( n 3 ) . Answer: Statements 1, 2, 4 and 5 are consistent. Note: For probem R, O(n 2 ) can be tight or loose upper bound and (n lg n) can be tight or loose lower bound. An algorithm that solves R can be so efficient that it achieves its complexity as the same as the problem ( but can not be smaller), or it can be so inefficient that it is much more complex (say, exponential) than the problem. 2. (10 points) For (a) and (b), answer yes or no and briefly explain. (a) If I prove that an algorithm takes O(n 2 ) worst-case time, is it possible that it takes O(n) time on some inputs? Answer: Yes. Note that O(n 2 ) worst-case time is an upper bound and we have not given a lower bound limit. Because Θ (n) is smaller than Θ (n 2 ) , it is possible that an algorithm satisfies both O(n 2 ) worst-case time and O(n) time on some inputs. (b)
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 5

Chapter3ProblemsSol - UML CS Analysis of Algorithms 91.404

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online