Chapter3ProblemsSol

# Chapter3ProblemsSol - UML CS Analysis of Algorithms 91.404...

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

UML CS Analysis of Algorithms 91.404 Spring, 2001 Homework Set #1 & SOLUTIONS 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.

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 ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern