Skip to content
Official PYQ · 2003

GATE CS 2003 Q39 — Sets, Relations and Functions

Explain with AI

Let Σ={a,b,c,d,e}\Sigma = \left\{a, b, c, d, e\right\} be an alphabet. We define an encoding scheme as follows:

g(a)=3,g(b)=5,g(c)=7,g(d)=9,g(e)=11g(a) = 3, g(b) = 5, g(c) = 7, g(d) = 9, g(e) = 11.

Let pip_i denote the i-th prime number (p1=2)\left(p_1 = 2\right).

For a non-empty string s=a1…ans=a_1 \dots a_n, where each ai∈Σa_i \in \Sigma, define f(s)=Πi=1nPig(ai)f(s)= \Pi^n_{i=1}P_i^{g(a_i)}.

For a non-empty sequence⟨sj,…,sn⟩\left \langle s_j, \dots,s_n\right \rangle of stings from Σ+\Sigma^+, define h(⟨si…sn⟩)=Πi=1nPif(si)h\left(\left \langle s_i \dots s_n\right \rangle\right)=\Pi^n_{i=1}P_i^{f\left(s_i\right)}

Which of the following numbers is the encoding, hh, of a non-empty sequence of strings?

Choose one option
View worked solution

Answer: B

To find which number represents a valid encoding h(⟨s1,…,sn⟩)h(\langle s_1, …, s_n \rangle), let us analyze the definitions of f(s)f(s) and hh:

  1. For any non-empty string s=a1a2…ars = a_1 a_2 \dots a_r, the encoding is defined as: f(s)=p1g(a1)p2g(a2)…prg(ar)=2g(a1)3g(a2)…prg(ar)f(s) = p_1^{g(a_1)} p_2^{g(a_2)} \dots p_r^{g(a_r)} = 2^{g(a_1)} 3^{g(a_2)} \dots p_r^{g(a_r)} where g(ai)∈{3,5,7,9,11}g(a_i) \in \{3, 5, 7, 9, 11\}. Thus, the exponent of each prime factor in f(s)f(s) must belong to the set {3,5,7,9,11}\{3, 5, 7, 9, 11\}.
  2. The sequence encoding is defined as: h(⟨s1,…,sn⟩)=2f(s1)3f(s2)…pnf(sn)h(\langle s_1, \dots, s_n \rangle) = 2^{f(s_1)} 3^{f(s_2)} \dots p_n^{f(s_n)}

The given options are all of the form 2k3k5k2^k 3^k 5^k for k∈{7,8,9,10}k \in \{7, 8, 9, 10\}. For h(⟨s1,s2,s3⟩)=2k3k5kh(\langle s_1, s_2, s_3 \rangle) = 2^k 3^k 5^k, we must have: f(s1)=f(s2)=f(s3)=kf(s_1) = f(s_2) = f(s_3) = k Let us test which value of kk can be a valid f(s)f(s) for some string s∈Σ+s \in \Sigma^+:

  • For k=8k = 8: We can write 8=238 = 2^3. Since 3∈{3,5,7,9,11}3 \in \{3, 5, 7, 9, 11\}, this matches the definition of f(s)f(s) for a single-character string s=as = a (where g(a)=3g(a) = 3). Thus, f(a)=2g(a)=23=8f(a) = 2^{g(a)} = 2^3 = 8.
    Choosing s1=s2=s3=as_1 = s_2 = s_3 = a, we get: h(⟨a,a,a⟩)=2f(a)3f(a)5f(a)=283858h(\langle a, a, a \rangle) = 2^{f(a)} 3^{f(a)} 5^{f(a)} = 2^8 3^8 5^8 This is a valid encoding.
  • For other options:
    • k=7=71k = 7 = 7^1 (exponents must be in {3,5,7,9,11}\{3, 5, 7, 9, 11\} and prime factors must start with 22).
    • k=9=32k = 9 = 3^2 (exponent 22 is invalid, and prime 22 is missing).
    • k=10=21⋅51k = 10 = 2^1 \cdot 5^1 (exponents are 11, which is invalid).

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Sets, Relations and Functions questions