{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# Exam2sol - Analysis of Algorithms On-campus Exam#2 solution...

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

Analysis of Algorithms On-campus Exam #2 solution Spring 2004 Page 1 of 2 Problem 1 (Graded by Rajendra): Algorithm: Since the given numbers are sorted in increasing order, let us start from the smallest number and try to fit in as many real numbers in this set, such that the difference between the smallest and the largest number in this range is <= 1. If not all real numbers could be accommodated because of the condition stated above, then start a new set with the next real number in line and fill it in the same manner. Go on doing this until the whole set of real numbers provided is exhausted. Proof of optimality: Lets us represent the set “i” of unit length of our greedy approach by [s i b i ] So let the solution given by our greedy approach (S G ) and by some other optimal approach(S O ) as follows : 1 2 …. k .... m S G Æ [s 1 b 1 ] [s 2 b 2 ] …[s k b k ] …. [s m b m ] S O Æ [S 1 B 1 ] [S 2 B 2 ] …[S k B k ] …. [S m B m ] Let us assume the sets in both solutions are similar till j < k. They differ in the set k.

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