• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

Context free languages and Push-down automata

Question 41

Which of the following languages over {a,b,c} is accepted by a deterministic pushdown automata? a. {wcw

R

∣ w∈ {a,b}* } b. {ww

R

∣ w∈ {a,b,c}* } c. {a

n

b

n

c

n

∣ n ≥ 0 } d. {w ∣ w is a palindrome over {a,b,c} }

Note

: w

R

  is the string obtained by reversing \'

w

\'

  • a

  • b

  • c

  • d

Question 42

If L1 and L2 are context free languages and R a regular set, one of the languages below is not necessarily a context free language, which one?
  • L1 . L2
  • L1 ∩ L2
  • L1 ∩ R
  • L1 ∪ L2

Question 43

Define for a context free language L ⊆ {0, 1}* ,  init(L)={uuv ∈ L for some v in {0,1}∗} ( in other words, init(L) is the set of prefixes of L) Let L = {w ∣ w is nonempty and has an equal number of 0’s and 1’s} Then init(L) is
  • the set of all binary strings with unequal number of 0\'s and 1\'s
  • the set of all binary strings including null string
  • the set of all binary strings with exactly one more 0 than the number of 1’s or one more 1 than the number of 0’s
  • None of the above

Question 44

Let G be a context-free grammar where G = ( { S, A, B, C}, { a,b, d}, P, S ) with the productions in P given below.
S → ABAC
A → aA ∣ ε
B → bB ∣ ε
C → d
(ε denotes null string). Transform the grammar G to an equivalent context-free grammar G\' that has no ε productions and no unit productions. (A unit production is of the form x → y, and x and y are non terminals.)

    Question 45

    Let Q = ( {q1,q2}, {a,b}, {a,b,Z}, δ, Z, ϕ) be a pushdown automaton accepting by empty stack for the language which is the set of all non empty even palindromes over the set {a,b}. Below is an incomplete specification of the transitions δ. Complete the specification. The top of the stack is assumed to be at the right end of the string representing stack contents.
    δ(q1, a, Z)={(q1, Za)}
    δ(q1, b, Z)={(q1, Zb)}
    δ(q1, a, a)={(..... , .....)}
    δ(q1, b, b)={(..... , .....)}
    δ(q2, a, a)={(q2, ϵ)}
    δ(q2, b, b)={(q2, ϵ)}
    δ(q2, ϵ, Z)={(q2, ϵ)}

      Question 46

      Consider the following context-free grammar over the alphabet ∑ = {a, b} with S as the start symbol:
      S → AT 
      A → aAa | bAb | #T 
      T → aT | bT | λ 
      
      Which of the following represents the language generated by the above grammar?
      • { w#x | w^R is a substring of x, where w, x ∈ {a, b}* }
      • { w#x | w is a substring of x, where w, x ∈ {a, b}* }
      • { x#w | w^R is a substring of x, where w, x ∈ {a, b}* }
      • { w#x | w, x ∈ {a, b}* }

      Question 47

      Consider the following context free languages:
      L1 = {0^i 1^j 2^k | i+j = k}
      L2 = {0^i 1^j 2^k | i = j or j = k}
      L3 = {0^i 1^j  | i = 2j+1}
      
      Which of the following option is true?
      • L1, L2 and L3 can be recognized by Deterministic Push down automata
      • L1, L2 can be recognized by Deterministic Push down automata
      • L1, L3 can be recognized by Deterministic Push down automata
      • None of the above

      Question 48

      Which of the following language(s) generates more than one parse tree for a string ?
      L1 = {a^nb^mc^md^n ∈ {a, b, c, d}* | n, m ≥ 0} 
            ∪ {a^nb^nc^md^m ∈ {a, b, c, d}* | n, m ≥ 0} 
      
      L2 = {a^nb^mc^m ∈ {a, b, c}* | n, m ≥ 0} 
            ∪ {a^nb^nc^m ∈ {a, b, c}* | n, m ≥ 0}
      
      L3 = {a^nb^mc^p ∈ {a, b, c}* | n ≠ m; n, m ≥ 0} 
            ∪ {a^nb^mc^p ∈ {a, b, c}* | m ≠ p; n, m ≥ 0}
      
      • Only L1 and L2
      • Only L1 and L3
      • Only L2 and L3
      • All L1, L2, and L3

      Question 49

      Consider the following grammars G1 and G2 respectively. Grammar - G1:
      A1 → A2A3
      A2 → A3A1 | b
      A3 → A1A1 | a
      
      Grammar - G2:
      S → AA | 0
      A → SS | 1
      
      Consider the following statements regarding above grammars: (I): This grammar is not left recursive and equivalent to grammar - G1:
      A1 → A2A3
      A2 →  A3A1 | b
      A3 → a | bA3A1 | aK | bA3A1K 
      k → A1A3A1 | A1A3A1K
      
      (II): This grammar is not left recursive and equivalent to grammar - G2:
      S → A A | 0
      A → 0S | 1 | 0SK | 1K
      K → AS | ASK
      
      • Only statement (I) is correct
      • Only statement (II) is correct
      • Both statements (I) and (II) are correct
      • Neither statement (I) not (II) is correct

      Question 50

      Consider the following languages: I. {ambncpdq ∣ m + p = n + q, where m, n, p, q ≥ 0} II. {ambncpdq ∣ m = n and p = q, where m, n, p, q ≥ 0} III. {ambncpdq ∣ m = n = p and p ≠ q, where m, n, p, q ≥ 0} IV. {ambncpdq ∣ mn = p + q, where m, n, p, q ≥ 0} Which of the above languages are context-free?
      • I and IV only
      • I and II only
      • II and III only
      • II and IV only
      1

      ...

      456

      ...

      10

      There are 93 questions to complete.

      Last Updated :
      Take a part in the ongoing discussion