11.
CS 514
IIT Guwahati
AUTUMN SEMESTER, 2011-2012
MATHEMATICS FOR COMPUTER SCIENCE
Mid-Semester Solutions
(Time allowed: TWO hours)
1. An arbitrary binary relation on a set A (which may not be a partial order) is called well-founded when
there is no inﬁnite -decreasing sequence
a0 a1 a2 . . . an . . .
of elements ai ∈ A, where is the inverse of . If B is a subset of A, an element b ∈ B is deﬁned to be
-minimal in B iﬀ there is no b ∈ B such that b b. Prove that is well-founded iﬀ every nonempty
subset of A has a -minimal element. (Size limit: half a page for each part) (10 marks)
ANSWER
(⇒) Suppose is well-founded. For contradiction, let B be a non-empty subset of A which has no -minimal
element. Choose any element b0 in B. Since b0 is not minimal, there is an element b1 ∈ B such that b0 b1.
Since b1 is not minimal either, there is an element b2 such that b1 b2. Continuing this argument we can
construct an inﬁnite -descending chain b0 b1 b2 . . . bn . . . in B, which is a contradiction.
(⇐) Suppose every non-empty subset of A has a minimal element. Then there cannot be an inﬁnite -
descending chain a0 a1 a2 . . . an . . . in A, since such a chain has no minimal element.
2. A robot wanders around a two-dimensional grid. It starts out at (0, 0) and is allowed to take four diﬀerent
types of steps:
(a) (+2, −1)
(b) (+1, −2)
(c) (+1, +1)
(d) (−3, 0)
Justify whether the robot can reach the position (0, 2) either by ﬁnding a path from (0, 0) to (0, 2) or by
using the Invariant Principle to prove that no such path exists. (Size limit: half a page) (10 marks)
ANSWER
12.
– 2 – CS 514
It is easy to check that the following predicate is a preserved invariant which is true of the initial state: “In
state (x, y) it is the case that x − y is divisible by 3”. So by the invariant principle, all reachable states
satisfy the predicate. But 0 − 2 is not divisible by 3. So (0, 2) is not reachable.
3. Fermat’s theorem states that if p is a prime and k is not a multiple of p then kp−1
≡ 1 (mod p). Let
Sk = 1k
+ 2k
+ . . . + (p − 1)k
, where p is an odd prime and k is a multiple of p − 1. Use Fermat’s theorem
to prove that Sk ≡ −1 (mod p). (Size limit: half a page) (10 marks)
ANSWER
We are given that p is an odd prime and k is a multiple of p − 1. Now for all i such that 1 ≤ i ≤ p − 1, p
does not divide i. Hence by Fermat’s theorem, ip−1
≡ 1 (mod p) for all i such that 1 ≤ i ≤ p − 1. Now
since, k = n(p − 1) for some integer n, we have ik
= in(p−1)
= (ip−1
)n
≡ 1n
≡ 1 (mod p) by repeated use
of the congruence property of multiplication. Then by using the congruence property of addition, the sum
Sk = Σp−1
i=1 ik
≡ 1 + 1 + 1 . . . + 1 (mod p) ≡ (p − 1) (mod p) ≡ −1 (mod p), since p ≡ 0 (mod p).
4. (a) In a round-robin tournament, every two distinct players play against each other just once. For a round-
robin tournament with no tied games, a record of who beat whom can be described with a tournament
digraph, where the vertices correspond to players and there is an edge < x → y > iﬀ x beat y in their
game. A ranking in a tournament digraph is a path that includes all the players. Give an example of a
tournament digraph on 3 vertices with more than one ranking. (Size limit: half a page) (5 marks)
ANSWER
3
1 2
(b) We say that a simple (i.e., undirected) graph has two ends if it has exactly two vertices of degree 1 and
all its other vertices have degree 2. A line graph is a graph whose vertices can be listed in a sequence
with edges between consecutive vertices only. Give an example of a two-ended graph which is not a
line graph. (5 marks)
(Size limit: half a page)
ANSWER
13.
– 3 – CS 514
5
1
2
3 4
5. For each of the statements below state whether it is true or false, and justify your claim by either giving a
proof or a counterexample.
(a) In every instance of the Stable Matching Problem, there is a stable matching containing a pair (m, w)
such that m is ranked ﬁrst by w, and w is ranked ﬁrst by m. (Size limit: half a page) (5 marks)
ANSWER
False. Suppose we have two men m, m and two women w, w . Let m rank w ﬁrst, w rank m ﬁrst, m
rank w ﬁrst and w rank m ﬁrst. We see that such a pair as described by the claim does not exist.
(b) Consider an instance of the Stable Matching Problem in which there exists a man m and a woman w
such that m is ranked ﬁrst by w, and w is ranked ﬁrst by m. Then (m, w) must appear in every stable
matching. (Size limit: half a page) (5 marks)
ANSWER
True. Suppose S is a stable matching that contains the pairs (m, w ) and (m , w), for some m , w
diﬀerent from m, w respectively . But clearly, (m, w) forms an unstable pair, contradicting the stability
of S.
14.
CS 514
IIT Guwahati
AUTUMN SEMESTER, 2012-2013
MATHEMATICS FOR COMPUTER SCIENCE
CS 514
Mid-Semester Answers
(Time allowed: TWO hours)
1. Express each of the following predicates and propositions in formal logic notation. The domain of discourse
is the set of natural numbers N. You may use predicates using only addition, multiplication and equality
symbols, and constants 0, 1, . . .. For example, the predicate “n is an even number” could be deﬁned by
∃m.(2m = n) or alternatively, by ∃m.(m + m = n).
• m is a divisor of n. (Size limit: one line) (2 marks)
• n is a prime number. (Size limit: one line) (3 marks)
ANSWER
• ∃k.n = km.
• ∀i.∀j.(n = ij → (i = 1) ∨ (i = n)).
2. Find a bijection from the half-open unit interval (0, 1] to the nonnegative numbers [0, ∞) = {x | x ≥ 0} on
the real line. Justify your answer. (Size limit: half a page) (10 marks)
ANSWER
Let f : (0, 1] → [0, ∞) be given by f(x) = 1
x − 1. Then f is a bijection since
• f(a) = f(b) implies 1
a − 1 = 1
b − 1 which implies a = b, so f is injective;
• every c in [0, ∞) is the image of 1
1+c ∈ (0, 1], so f is surjective.
3. We start with 102 coins on a table, 98 showing heads and 4 showing tails. There are two rules for changing
the coins:
• ﬂip over any ten coins (any coin that is ﬂipped changes from heads to tails, and vice versa), or
15.
– 2 – CS 514
• let n be the number of heads showing. Place n + 1 additional coins, all showing tails on the table.
(a) Model the situation as a state machine, specifying the state space, the initial state and the transi-
tions. (4 marks)
(b) Prove that it is not possible to reach a state in which there is exactly one head showing (nothing is said
about the number of tails – it could be anything). (Size limit: one page) (10 marks)
ANSWER
(a) A state is a pair (x, y) where x and y are the numbers of heads and tails, respectively. The initial state
is (98, 4). The transitions are of two types:
• (x, y) −→ (x − a + b, y − b + a) where a ≤ x, b ≤ y and a + b = 10. Here a and b are the number of
heads and tails that are ﬂipped.
• (x, y) −→ (x, x + y + 1).
(b) We assert that P(x) = x is even is a preserved invariant which is true in the initial state. This is
because 98 is even (initial state) and x is even implies x − a + b = x − a + 10 − a = x + 10 − 2a is even. The
other transition is easy since the value of x is unchanged. This means P(x) is true in all reachable states.
So any state with exactly one head showing is not reachable.
4. Given a probability space (Ω, F, P), show that (B, {A ∩ B : A ∈ F}, P(.|B)} is again a probability-space,
where B ∈ F and P(.|B) is conditional probability. (6 marks)
ANSWER
[Remark: Only the outline is given.]
Given that (Ω, F, P) is probability-space.
Need to show that (B, {A ∩ B : A ∈ F, P(.|B)) is again a probability-space.
i.e. need to show that {A ∩ B : A ∈ F} is σ−ﬁeld deﬁned over the sample space B. (Straight-forward to
show and hence omitted)
and P(.|B) is probability measure over {A ∩ B : A ∈ F}.
To show P(.|B) is probability measure, show that P(B|B) = 1 and
P(.|B) is countably-additive (This has been already discussed in the class).
5. (a) What is the probability of getting the word ABRACADABRA by shuﬄing 5 As, 2 Bs, 2 Rs, 1 C and
1 D randomly. (2 marks)
(b) Two cards are drawn independently with replacement from a well-shuﬄed deck of 52 cards. All cards
are equally likely at each selection. What is the probability that the king of spades & the king of hearts
will be chosen (in some order). (2 marks)
ANSWER
16.
– 3 – CS 514
(a) 11 letters can arrange in 11! ways. 5 As can arrange in 5! ways and similarly for other letters.
Hence the required probability is 5!2!2!
11! .
(b) Each card can be selected with probability = 1
52 .
As the two cards are selected with replacement and order is important (as per the question)
then the reqd probability = P(king of spade)∗P(king of hearts)+P(king of hearts)∗P(king of spade)
= 2
522
6. A communication system consists of n-components each of which will independently function with probability
p. The total system will be able to operate eﬀectively if at least one-half of its components function.
(a) For what values of p is a 5-component system more likely to operate eﬀectively than a 3-component
system? (3 marks)
(b) In general, when is a (2k + 1)-component system better than a (2k − 1)- component sys-
tem? (4 marks)
ANSWER
(a) Observe that the number of functioning components is a binomial random variable with the parameters
(n, p). The probability that the 5−component system will be eﬀective is
5
3
p3
(1 − p)2
+
5
4
p4
(1 − p) + p5
(1)
and the corresponding probability for 3− component system is
3
2
p2
(1 − p) + p3
(2)
Hence, the 5−component system is better if eq 1 ≥ eq 2
And solving the inequality will give answer p ≥ 1
2
(b) With similar logic, ﬁrst write down P(eﬀective 2k + 1 system) and P(eﬀective 2k − 1 system). And
solve the inequality, which again will give p ≥ 1
2 . Lets take X as number of ﬁrst 2k − 1 component
which works, then
P(eﬀective 2k+1 system) = P(X ≥ k + 1) + P(X = k)(1 − (1 − p)2
) + P(X = k − 1)p2
The above equation basically says the (2k + 1)−system will work if either
(i) X ≥ k + 1, or
(ii) X = k and at least one of the remaining 2 components works, or
(iii) X = k − 1 and both of the next 2 functions.
Similarly
P(eﬀective 2k-1 system) = P(X ≥ k) = P(X = k) + P(X ≥ k + 1)
17.
– 4 – CS 514
7. The joint density function of random variables X and Y is given by
f12(x, y) =
4xy if 0 ≤ x ≤ 1, 0 ≤ y ≤ 1, x ≥ y
6x2
if 0 ≤ x ≤ 1, 0 ≤ y ≤ 1, x < y
0 otherwise.
(a) Find the individual density function f1 and f2. (4 marks)
(b) If A = {X ≤ 1
2 }, B = {Y ≤ 1
2 }, ﬁnd P(A ∪ B). (4 marks)
ANSWER
(a) This part is easy and similar examples were solved in the class.
(b) First recall that
P(A ∪ B) = P(A) + P(B) − P(A ∩ B).
You have already calculated marginal densities in the part (a), hence that can be used to calculate
P(A) and P(B). P(A ∩ B) can be calculated using the given joint density.
Be the first to comment