.Trashed-1699212035-Final MST 22-23 Solution
.Trashed-1699212035-Final MST 22-23 Solution
Q1(a) Show that if f and g are real-valued functions such that f(x) is O(g(x)), then for every positive integer (2)
n, f n(x) is O(gn(x)). [Note that f n(x) = f(x)n].
Solution: Because f (x) is O(g(x)), there are constants C and k such that
|f (x)| ≤ C|g(x)| for x > k.
Hence, |f n(x)| ≤ Cn|gn(x)| for x > k, so f n(x) is O(gn(x)) by taking the constant to be Cn.
Marking Scheme:
If the answer is partially correct and no valid explanation: 0.5
If the answer is correct and no valid explanation: 1
If a valid justification is given with answer 1.5-2 (depending upon the explanation)
Q1(b) An unusual species inhabits the forest surrounding Functional City. Each member of the species can
take one of three possible forms, called Schemander, Haskeleon, and Camlizard. (4)
In January of every year, each individual undergoes “evolution”—a process by which the individual
splits into two individuals, whose forms depend on the form of the original:
• A Schemander splits into a Schemander and a Haskeleon.
• A Haskeleon splits into a Schemander and a Camlizard.
• A Camlizard splits into a Schemander and a Haskeleon.
It is known that in June of year 0, the population consisted of a single Schemander. Assume that no
individual ever dies and that all individuals successfully undergo evolution exactly once. Let Sn, Hn,
and Cn be the number of Schemanders, Haskeleons, and Camlizards, respectively, in June of year n.
i. Express Sn, Hn, and Cn in terms of Sn-1, Hn-1, and Cn-1, for n > 0.
ii. Let Tn = Sn + Hn + Cn be the total number of individuals in June of year n. Show that
Hn = Tn-1 - Hn-1, for n > 0.
Note: Sn, Hn, and Cn are also denoted as 𝑺(𝒏), 𝑯(𝒏)𝒂𝒏𝒅 𝑪(𝒏).
Part i)
Part ii)
1/2
Marking Scheme: 2 marks for each part (i and ii),
If the answer is partially correct and no valid explanation: 0.5
If the answer is correct and no valid explanation: 1
If a valid justification is given with answer 1.5-2 (depending upon the explanation)
Q2 Consider inserting the keys 10, 22, 31, 4, 15, 28, 17, 88, and 59 into a hash table of length m = 11 (6)
using open addressing with the primary hash function h'(k) = k mod m. Illustrate the result of
inserting these keys using linear probing, using quadratic probing with c1 = 1 and c2 = 3, and using
double hashing with h2(k) = 1 + (k mod (m - 1)).
Solution:
Marking Scheme:
[Total 6 marks] 2 marks for each hashing approach
2 marks: Everything is correct
1.5 marks: Minor calculation mistakes
1 mark: Logically correct but calculation mistakes
Q3 Use Warshall’s algorithm to find the transitive closure of the relation defined on set A = {a, b, c, d, e} (6)
as shown in Fig.1. Clearly explain each step of the algorithm.
2/2
a
b c
d e
Fig. 1
Solution:
Marking Scheme:
1 Marks for each correct matrix (W1 to W5 5 Marks)
If the final transitive closure is written – 1 Marks
Marks will be deducted from 1 if the matrices contain wrong entries
Q4(a) Suppose that there are four friends whose names are Daenerys (D), Cersei (C), Arya (A) and Sansa (S). (3)
On the occasion of Diwali, few members are sending an e-mail to either of friends or herself. Hence, a
relation is being derived with respect to the mails sent in this process and this relation is R={(D,C),
(D,S), (A,A), (S,D)}. Nahor is assigned the task to find a smallest relation containing R such that the
3/2
new relation would be
i. Reflexive and Transitive
ii. Symmetric and Transitive
iii. Reflexive, Symmetric and Transitive
Note that you have to make distinct relations for i - iii.
Q4(b) Let ℤ be the set of integers and ℤ∗ = ℤ − {0}. Let R be the following relation defined on ℤ × (3)
ℤ∗ : (𝑎, 𝑏)𝑅(𝑐, 𝑑) if 𝑎𝑑 = 𝑏𝑐. Prove that R is an equivalence relation.
Solution:
Marking Scheme:
Q5(a) Out of 60 students in a class, anyone who has chosen to study maths elects to do physics as well. But (3)
no one does maths and chemistry, 16 do physics and chemistry. All the students do at least one of the
three subjects and the number of people who do exactly one of the three is more than the number
who do more than one of the three. What are the maximum and minimum number of people who
could have done Chemistry only?
Solution: 44 and 0
Maths is a subset of Physics.
4/2
No one does maths and chemistry, 16 do physics and chemistry.
Number outside is 0 as all the students do at least one of the three subjects
Q5(b) Let R = {(a, b), (b, c), (c, a)} be a relation defined on set A = {a, b, c}. Find the symmetric closure of R 2 (3)
using Matrix representation.
Solution:
5/2
Symmetric Closure:
0 1 1
[1 0 1]
1 1 0
Marking Scheme:
6/2