ESO207 Theoretical Assignment 1 Semester II, 2016-17
ESO207 Theoretical Assignment 1 Semester II, 2016-17
Design an O(n) algorithm that given the sequence Y as input, chooses a sequence X such the value of C is
maximum. The algorithm needs to output only the value of the maximum such C. Prove the correctness
of your algorithm. See the following examples:
Example 1: Y = (10,5,7,3,9). Then your algorithm should output 29. ( As X = (10,1,7,1,9) is a valid
sequence that maximizes the sum C ).
Example 2: n=4, Y = (10,5,5,9). Then your algorithm should output 17. ( As X= (10,1,1,9) is a valid
sequence that maximizes the sum C )
4. (13 points) Give an algorithm to design a tournament consisting of n players so as to correctly identify the
top three players in the tournament, such that the number of matches is minimized in the tournament.
What is the minimum number of matches that such a tournament must have (as a function of n)?
Assume the following:
- for any two players, say A and B; if A is a better player than B, then A will defeat B in any match
played between them irrespective of any factors.
- for any three players, say A, B and C; if A defeats (is better than) B and B defeats (is better than)
C then A can be assumed to defeat (be better than) C.
- no match ever ends in a draw, i.e. between any two players we can always say one of them is better
than the other.
- before the tournament no information is known about the players.