You are on page 1of 10

# Problem 1: Help the tree of souls (300 points)

## “Assigning priorities to the concurrent prayers” maps to the “orientation of an

interval graph”, prayers being the intervals. The execution time of the prayers
corresponds to one more than the maximum path-length (i.e. diameter) of the
directed interval graph”.

## Given an undirected interval graph G, it is required to find an orientation of G,

say D, such that the diameter of D is minimized. Only the (length of minimum
diameter + 1 ) needs to be reported.

## According to Gallai-Roy-Vitavar theorem (pg 196, Introduction to Graph The-

ory by Douglas B. West), this is same as the chromatic number of the undirected
parent interval graph.

## Chromatic number of an interval graph is the same as it’s maximum clique

size.

Algorithm:

Sort the start times of the prayers. Sort the end times of the prayers. Find
the maximum clique size using linear traversal through the sorted start and end
times.

## Space Complexity: O(n)

1
Problem 2: Even if you don’t want to, help the
Villain (100 points)
There are four infinite families of graphs together with a few isolated special
cases which satisfy the criterion.

• Case 1

• Case 2

• Case 3

• Case 4

Reference:

## 1.http : //www.ics.uci.edu/ eppstein/junkyard/dilation − f ree/

2
Problem 3: To Err is Jake (250 points)
The problem basically is asking to find the maximum similarity measure among
all possible overlap of points in P by points in Q. The similarity measure for an
arrangement can be defined as:

## SM = { Number of points in P which are overlapped by Q } - { Number of

points in P which lie on/inside the convex hull of Q and are not overlapped by
any points in Q } - { Number of points in Q which do not overlap any point in P }

Let P has p points and Q has q points. A simple algorithm for solving this
problem can be to start matching one point in Q with another point in P. Using
the co-ordinate shifting for other points in Q accordingly, we can find the num-
ber of points in P which are overlapped by Q. Let there be m matching points.
We then need to find the number of unmatched points in P which lie on/inside
the convex hull of Q. Let there be y such points. The number of points in Q
which do not overlap any point in P will be x = q − m. Hence the similarity
measure for this arrangement will be SM = m − y − x

## A dynamic programming approach can be used to reduce the algorithm com-

plexity by avoiding repetitions in overlap of points in P and Q.

## Worst case complexity O(p2 q 2 )

3
Problem 4: Help Jake Sully learn Na’vi! (200
points)
We use a probabilty distribution approach to identify the Na’vi translations
of the English words. It will help us in resolving any ambiguities presented in
the training sentences.

## We first create a N xN matrix, where N is the number of words in English/Na’vi.

For each input sentence we have a set of English words which have a certain
probability (f rac1n ; n= number of words in that sentence) of having a trans-
lation in the corresponding Na’vi sentence for that input. For an English word
i and a Na’vi word j appearing in one training sentence, we add the probability
to the (i, j) element in the matrix. This is done for the entire input sentences
and each word pair in English-Na’vi. After this we sort the N 2 elements in the
matrix in descending order. The largest element (p, q) gives the translation for
English word p to be q in Na’vi. Then both p and q are removed for any further
translation. We pick the next largest element with a valid word (a word whose
translation is not found already) and find it’s translation accordingly. This way,
we can find the translation for the entire vocabulary.

## The order of complexity would be O(V 2 (logV )) ; V = Number of words in

English

4
Problem 5: Battle Formation (100 points)
In this problem, the strengths of the armies are immaterial, since all of them are
positive distinct integers. All you need to find is the number of permutations of
the set A = {1, 2, ....N } which have atmost k inversions.

## An inversion is defined as follows:

In a permutation of the above set if for some i < j, if A[i] > A[j], then it
is taken as one inversion. The number of inversions modulo 1000 is the required
answer.

Let C(N, k) denote the number of permutations of the set with atmost k inver-
sions.

Then we have,

C(0, 0) = 1

## USe Dynamic programming to obtain a O(N k) solution

5
Problem 6: Saving The Tree of Souls (150 points)
This problem requires expresing N as an ordered sum such that each num-
ber is congruent to 2 modulo 3. This is the number P(N-4) where P(N) is the
Padovan Sequence. Defined as:

## P (0) = P (1) = P (2) = 1

P (N ) = P (N − 2) + P (N − 3) for N ≥ 3

Reference:

## 1. http : //en.wikipedia.org/wiki/P adovan sequence

6
Problem 7: Infiltration!! (150 points)
An angular sweep from 0 to 45 degrees taking into account all the circles
at integral points which completely lie in the circle will give the non-visible
length/angle for 45 degrees. This can be multiplied by 8 to get total non-visible
length. The circles can be approximated to lines with end-points as the points
of contact of the tangents from the origin to the circle.

Reference:

## 1. http : //mathworld.wolf ram.com/OrchardV isibilityP roblem.html

7
Problem 8: Guarding the Settlement (300 points)
The layout of buildings provided is the graph W4 × Pn where W4 is the graph
K4 with one edge removed, and Pn path graph with n vertices.You were asked
to find the total number of domino tilings of this graph.

The solution to this problem is actually fn+1 ∗ pn+1 where fn is the nth Fi-
bonacci number and pn is the nth Pell number.

## f1 = 1,f2 = 1,fn+2 = fn+1 + fn for all n > 0

Complexity = O(N )

Reference:

## 1. Domino Tilings and Products of Fibonacci and Pell Numbers by

James A.Sellers

8
Problem 9: Summoning the Toruk (200 points)
This problem needed one to use the Chinese Remainder Theorem . One could
take any of the son’s party day as base , and calculate the remainder of that
day modulo the other periods . Once this is done , one could easily use Chinese
Remainder theorem to solve how many days are left until the next occurance
. Since the periods of parties were mutually prime , the Chinese Remainder
Theorem was applicable .

9
Problem 10: Help the chef (150 points)
One had to follow a dynamic programming approach . The best solution to
splitting n packets into ingreadients would be to select k packets of one ingredi-
ent , along with the best arrangement for the remaining n-k packets. Once the
solution was built up using memoization would lead to answer to all the test
cases in constant time.

10