Chennai Mathematical Institute: M.Sc. / Ph.D. Programme in Computer Science
Chennai Mathematical Institute: M.Sc. / Ph.D. Programme in Computer Science
Instructions
− −
• Enter your Admit Card Number : C
• Answer questions for Part A in the special answer sheet provided for it.
• Rough Work: The coloured blank pages are to be used for rough work only.
1 1 Part A
2 2 Part B
3 3 Total
4 4
5 5
6 6
7 7
8 Total
10
Total
CHENNAI MATHEMATICAL INSTITUTE
M.Sc. / Ph.D. Programme in Computer Science
Entrance Examination, 18 May 2017
Instructions
• Answer all questions for Part A on this sheet only.
a b c d
10
CHENNAI MATHEMATICAL INSTITUTE
M.Sc. / Ph.D. Programme in Computer Science
Entrance Examination, 18 May 2017
This question paper has 5 printed sides. Part A has 10 questions of 3 marks each. Part B has
7 questions of 10 marks each. The total marks are 100. Answers to Part A must be filled in
the answer sheet provided.
Part A
1. The regular expression (a∗ + b)∗ is equivalent to which of the following regular expres-
sions:
(a) a∗ b∗ (b) (a∗ b + b)∗ (c) (a + b∗ )∗ (d) (a∗ b)∗
2. An FM radio channel has a repository of 10 songs. Each day, the channel plays 3
distinct songs that are chosen randomly from the repository.
Mary decides to tune in to the radio channel on the weekend after her exams. What
is the probability that no song gets repeated during these 2 days?
10 2 10 −1
(a) 3
· 6
10 10 −2
(b) 6
· 3
10 7 10 −2
(c) 3
· 3
· 3
10 7 10 −1
(d) 3
· 3
· 6
3. Four siblings go shopping with their father. If Abhay gets shoes, then Asha does not
get a necklace. If Arun gets a T-shirt, then Aditi gets bangles. If Abhay does not get
shoes or Aditi gets bangles, the mother will be happy. Which of the following is true?
4. City authorities are concerned about traffic accidents on major roads. They would like
to have ambulances stationed at road intersections to quickly reach the scene of any
accident along these roads. To minimize response time, ambulances are to be located
at intersections with traffic lights so that any segment of road can be reached by at
least one ambulance that does not have to pass through a traffic light to reach the
scene of the accident. If we model the road network as a graph, where intersections
with traffic lights are vertices and edges represent road segments between traffic lights,
the graph theoretic question to be answered is:
1
(c) Find a minimal colouring.
(d) Find a minimum size vertex cover.
function foo(n,d){
if (d == 0){
return 1;
}else{
if (d < 0){
return foo(n,d+1)/n;
}else{
return n*foo(n,d-1);
}}}
f(){ g(){
w = 5; z = w+1;
w = 2*z + 2; z = 3*z - w;
} print(z);
}
We start with w and z set to 0 and execute f() and g() in parallel—that is, at each
step we either execute one statement from f() or one statement from g(). Which of
the following is not a possible value printed by g()?
(a) -2 (b) -1 (c) 2 (d) 4
2
8. A stable sort preserves the order of values that are equal with respect to the comparison
function. We have a list of three dimensional points
[(7, 1, 8), (3, 5, 7), (6, 1, 4), (6, 5, 9), (0, 2, 5), (9, 0, 9)].
We sort these in ascending order by the second coordinate. Which of the folllowing
corresponds to a stable sort of this input?
(a) [(9, 0, 9), (7, 1, 8), (6, 1, 4), (0, 2, 5), (6, 5, 9), (3, 5, 7)]
(b) [(0, 2, 5), (3, 5, 7), (6, 1, 4), (6, 5, 9), (7, 1, 8), (9, 0, 9)]
(c) [(9, 0, 9), (7, 1, 8), (6, 1, 4), (0, 2, 5), (3, 5, 7), (6, 5, 9)]
(d) [(9, 0, 9), (6, 1, 4), (7, 1, 8), (0, 2, 5), (3, 5, 7), (6, 5, 9)]
9.
15
Suppose we constructed the binary
search tree shown at the right by start-
ing with an empty tree and inserting 7 28
one element at a time from an input se-
quence, without any rotations or other
manipulations. Which of the following 3 12 19 37
assertions about the order of elements
in the input sequence cannot be true?
1 6 8 14 16 23 29 42
(a) If the best algorithm for B takes exponential time, there is no polynomial time
algorithm for A
(b) If the best algorithm for A takes exponential time, there is no polynomial time
algorithm for B.
(c) If we have a polynomial time algorithm for A, we must also have a polynomial
time algorithm for B.
(d) If we don’t know whether there is a polynomial time algorithm for B, there cannot
be a polynomial time algorithm for A.
Part B
1. Let Σ = {a, b, c}. Let Leven be the set of all even length strings in Σ∗ .
3
(b) We consider an operation Eraseab that takes as input a string w ∈ Σ∗ and erases
all occurrences of the pattern ab from w. Formally, it can be defined as follows:
(
w if w does not contain the pattern ab
Eraseab (w) :=
Eraseab (w1 ) Eraseab (w2 ) if w = w1 ab w2 for some w1 , w2 ∈ Σ∗
For instance, Eraseab (cacb) = cacb, Eraseab (cabcbab) = ccb and Eraseab (ab) = .
For a language L, we define Eraseab (L) to be the set of strings obtained by applying
the Eraseab operation to each string in L:
2. There are a number of tourist spots in a city and a company GoMad runs shuttle
services between them. Each shuttle plies between a designated origin and destination,
and has a name. Due to lack of coordination, the same name may be allotted to
multiple routes.
To make matters worse, another company GoCrazy introduces its shuttle services
using the same set of shuttle names. A GoMad shuttle and a GoCrazy shuttle with
the same name may start at different origins and/or end at different destinations.
A pass from a company allows unlimited travel in all the company’s shuttles. For each
company, we have a list that specifies all routes allotted to each shuttle name.
Design an algorithm to find out if there is a source s, a target t, and a sequence of
shuttle names σ such that, irrespective of whether you are carrying a GoMad pass or
a GoCrazy pass, you can start at s and arrive at t using the sequence σ.
3. Let Σ = {a, b}. Given words u, v ∈ Σ∗ , we say that v extends u if v is of the form xuy
for some x, y ∈ Σ∗ . Given a fixed word u, we are interested in identifying whether a
finite state automaton accepts some word that extends u.
Describe an algorithm that takes as input a finite state automaton (DFA or NFA) A
over Σ = {a, b} and a word u ∈ Σ∗ and reports “Yes” if some word in the language of
A extends u and “No” if no word in the language of A extends u.
5. An undirected graph is connected if, for any two vertices {u, v} of the graph, there is
a path in the graph starting at u and ending at v. A tree is a connected, undirected
graph that contains no cycle.
(a) A leaf in a tree is a vertex that has degree 1. Prove that if G is a tree with at
least two vertices then G contains at least two leaves.
4
(b) A bipartite graph is one in which the vertex set V can be partitioned into two
disjoint sets V1 and V2 so that for every edge {u, v}, u and v lie in different
partitions—that is, u ∈ V1 and v ∈ V2 or vice versa. Prove that if G is a tree
with at least two vertices, then G is bipartite.
6. We are given a sequence of pairs of integers (a1 , b1 ), (a2 , b2 ), . . . (an , bn ). We would like
to compute the largest k such that there is a sequence of numbers ci1 ≤ ci2 ≤ . . . ≤ cik
with 1 ≤ i1 < i2 < ... < ik ≤ n and for each j ≤ k, cij = aij or cij = bij . Describe an
algorithm to solve this problem and explain its complexity.
7. Consider the following function that takes as input a sequence A of integers with
n elements, A[1], A[2], . . . , A[n] and an integer k and returns an integer value. The
function length(S) returns the length of sequence S. Comments start with //.
v = A[1];
AL = [ A[j] : 1 <= j <= n, A[j] < v ]; // AL has elements < v in A
Av = [ A[j] : 1 <= j <= n, A[j] == v ]; // Av has elements = v in A
AR = [ A[j] : 1 <= j <= n, A[j] > v ]; // AR has elements > v in A