pgcs2024
pgcs2024
Part A has 10 questions of 3 marks each. Each question in Part A has four choices, of which
exactly one is correct. 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.
In all questions related to graphs, unless otherwise specified, we use the word “graph” to mean
an undirected graph with no self-loops, and at most one edge between any pair of vertices.
Part A
1. All inhabitants of the Old Forest are either Ents or Bents. Ents always tell the truth
and Bents always lie. During a visit to the Old Forest, you encounter four inhabitants
– A, B, C and D. They make the following assertions.
2. Friends Akshay and Bipasha go to a fun fair, and decide to explore the stalls separately.
Each of them visits a stall every 10 minutes, starting at 8am. If a stall that Akshay
visits is one that he has not seen before, he texts new to Bipasha; otherwise he texts
old. If a stall that Bipasha visits is new to her she texts new to Akshay; otherwise
she texts old. A round refers to such a pair of messages, one sent by Akshay and the
other sent by Bipasha. If there are 50 stalls, what is the maximum number of rounds
they can go before both of them text old to each other in the same round?
(a) 99 (b) 100 (c) 2500 (d) 50
1
3. You live in ∆-City, which is a large equilateral triangle with each side of length 2km.
The corners are named A, B and C. The city is partitioned into triangular blocks
with sides of 500m each, and there are roads at the boundaries of the blocks.
You live in corner A and your office is at corner B.
B C
You have decided to walk from home to the office everyday, and you are willing to
change your route, as long as the total distance is at most 2.5kms. How many such
routes are possible from A to B?
(a) 5 (b) 11 (c) 21 (d) 45
4. Rohit and Ben participate in a new toss system introduced by the ICC. The umpire
repeatedly tosses a fair coin (which comes up heads with probability 21 and tails with
probability 12 ), until one of them wins. Rohit wins if the result of two consecutive
tosses is heads (i.e., the pattern HH is seen), while Ben wins if the pattern TH is seen.
What are the winning probabilities for Rohit and Ben?
1 3 1 1 1 1 1 2
(a) 4
and 4
(b) 4
and 4
(c) 2
and 2
(d) 3
and 3
5. Let Σ = {a, b, c}. What is the language generated by the following grammar?
S := ϵ | aS | Sb | cS
2
7. Consider the following two recurrence relations:
8. Let G be an undirected connected graph with distinct edge weights. Let emax be the
edge with maximum weight and emin the edge with minimum weight. What can you
say about the following statements?
(I) Every shortest s-t path (minimum weight) must include the minimum-weight
edge of G.
(II) Every shortest s-t path must exclude the maximum-weight edge of G.
3
Part B
1. A binary search tree is a binary tree whose proper subtrees are binary search trees,
and whose root is strictly greater than all elements in the left subtree, and strictly
less than all elements in the right subtree. A preorder listing of a tree is obtained by
listing the root first, then recursively listing all elements of the left subtree in preorder,
followed by all elements of the right subtree in preorder.
Provide algorithms for the following two problems, and calculate their worst-case run-
ning times.
(a) Input is an array of integers A[1..n]. Output is “Yes” if A is the preorder listing
of a binary search tree, and “No” otherwise.
(b) Input is an array of integers A[1..n] which is guaranteed to be the preorder listing
of a binary search tree. Output is a binary tree t such that A is the preorder
listing of t.
• Q2 = Q1 .
• q2 = q1 .
• F2 = F1 ∪ {q1 }.
• (p, a, p′ ) ∈ ∆2 iff either (p, a, p′ ) ∈ ∆1 or (p ∈ F1 and a = ϵ and p′ = q1 )
3. You are using a fair coin to walk along the number line, starting at position 0. You
toss the coin. If you get heads you move two steps to your right, to position 2. On
the other hand if you get tails you move one step to your right, to position 1. You
continue tossing the coin. Every time you get heads you move two steps to the right
of the position you are in currently, and if you get tails you move one step to the right
of the position you are in currently.
Show that the probability of landing in position n is
1 1
[2 + (− )n ]
3 2
.
4. Suppose all points on the 2D plane with integer coordinates are coloured either blue
or green. Show that there is an isosceles right angled triangle all of whose vertices are
the same colour.
4
(b) Prove or disprove the following statement: w ∈ L ∩ rev(L) iff w = rev(w).
(c) Show that if L is regular, rev(L) is also regular.
6. A tournament is a directed graph that has exactly one directed edge between each
pair of vertices. A king in a tournament is a vertex v such that every other vertex is
reachable from v via a directed path of length at most 2.