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

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

View Full Document Right Arrow Icon
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.
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.

This note was uploaded on 11/30/2011 for the course COT 5405 taught by Professor Ungor during the Fall '08 term at University of Florida.

Page1 / 2

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

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