Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Tests  >  Test: Context Free Grammar - Computer Science Engineering (CSE) MCQ

Test: Context Free Grammar - Computer Science Engineering (CSE) MCQ


Test Description

10 Questions MCQ Test - Test: Context Free Grammar

Test: Context Free Grammar for Computer Science Engineering (CSE) 2024 is part of Computer Science Engineering (CSE) preparation. The Test: Context Free Grammar questions and answers have been prepared according to the Computer Science Engineering (CSE) exam syllabus.The Test: Context Free Grammar MCQs are made for Computer Science Engineering (CSE) 2024 Exam. Find important definitions, questions, notes, meanings, examples, exercises, MCQs and online tests for Test: Context Free Grammar below.
Solutions of Test: Context Free Grammar questions in English are available as part of our course for Computer Science Engineering (CSE) & Test: Context Free Grammar solutions in Hindi for Computer Science Engineering (CSE) course. Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free. Attempt Test: Context Free Grammar | 10 questions in 30 minutes | Mock test for Computer Science Engineering (CSE) preparation | Free important questions MCQ to study for Computer Science Engineering (CSE) Exam | Download free PDF with solutions
Test: Context Free Grammar - Question 1

The entity which generate Language is termed as:

Detailed Solution for Test: Context Free Grammar - Question 1

The entity which accepts a language is termed as Automata while the one which generates it is called Grammar. Tokens are the smallest individual unit of a program.

Test: Context Free Grammar - Question 2

Which of the following statement is false?

Detailed Solution for Test: Context Free Grammar - Question 2

Every regular language can be produced by context free grammar and context free language can be produced by context sensitive grammar and so on.

1 Crore+ students have signed up on EduRev. Have you? Download the App
Test: Context Free Grammar - Question 3

Which among the following cannot be accepted by a regular grammar?

Detailed Solution for Test: Context Free Grammar - Question 3

There exists no finite automata to accept the given language i.e. 0n1n. For other options, it is possible to make a dfa or nfa representing the language set.

Test: Context Free Grammar - Question 4

For S->0S1|e for ∑={0,1}*, which of the following is wrong for the language produced?

Detailed Solution for Test: Context Free Grammar - Question 4

L = {e, 01, 0011, 000111, ……0n1n}. As epsilon is a part of the set, thus all the options are correct implying none of them to be wrong.

Test: Context Free Grammar - Question 5

Which of the following statement is correct?

Detailed Solution for Test: Context Free Grammar - Question 5

Regular grammar is a subset of context free grammar and thus all regular grammars are context free.

Test: Context Free Grammar - Question 6

Which of the following is sufficient to convert an arbitrary Context Free Grammar (CFG) to an LL(1) grammar?

Detailed Solution for Test: Context Free Grammar - Question 6

LL(1) Grammar: The first 'L' refers to scanning of input from Left to Right, the second 'L' refers to producing the Leftmost Derivation and the (1) stands for using only 1 lookahead input symbol at each step to make parsing action decisions. Hence, a context-free grammar G = (VT, VN, S, P) whose parsing table has no multiple entries is said to be LL(1) Grammar.

LL(1) Conflicts:

  • Checking whether a grammar is ambiguous or not is undecidable.
  • A grammar can be LL(1) only if it is not ambiguous, not left recursive and it must not contain left factoring and vice-versa is not necessary.
  • Any regular language can be LL(1) is true statement since we can write regular grammar which follows the above conflict.

Since a grammar is LL(1) only if it does not contain left recursion, ambiguity and left factoring, hence, to convert an arbitrary CFG to LL(1), all the three should be eliminated

*Answer can only contain numeric values
Test: Context Free Grammar - Question 7

To derive the string length 4, How many minimum productions are required for Chomsky normal form ?


Detailed Solution for Test: Context Free Grammar - Question 7

Concept:
Chomsky's normal form:
A Chomsky normal form follows the,
V→VV (Exactly 2 non-terminals)
V is Non-terminals
V→T (Exactly one terminal)
T is terminal
If length n=1, Number of productions = 1
S→a
If length n=2, Number of productions = 3
S→AB
A→a
B→b
If length n=3, Number of productions = 5
S→AX
X→BC
A→a
B→b
C→c
According to this, If length n, the number of productions = (2n-1) is required.
n=4,
then,
(2(4)-1)= 7 productions
Hence the correct answer is 7.

Test: Context Free Grammar - Question 8

A student wrote two context-free grammars G1 and G2 for generating a single C-like array declaration. The dimension of the array is at least one. For example,
int a[10] [3] ;
The grammars use D as the start symbol, and use six terminal symbols int; id[ ] num

Which of the grammars correctly generate the declaration mentioned above?

Detailed Solution for Test: Context Free Grammar - Question 8

Grammar G1 is:
D → int L;
L → id [E
E → num]
E → num] [E
Generate one dimensional array: a[10]
D → int L
→ int id[E
→ int id[num]
This leads to int a[10]
Generate two-dimensional array: int a [10] [3];
D → int L;
→ int id [E;
→ int id [num] [E;
→ int id [num] [num];
This leads to int a[10][3]
It correctly generates declaration given.
Grammar G2 is:
D → int L;
L → idE
E → E[num]
E → [num]
Generate one dimensional array: a[10]
D → int L;
→ int idE
→ int id[num]
This leads to int a[10]
Generate two-dimensional array: int a [10] [3];
int a[10][3];
D → int L;
→ int id E;
→ int id E[num];
→ int id [num] [num];
This leads to int a[10][3]
So, both grammar G1 and G2 generates the given declaration.

Test: Context Free Grammar - Question 9

Consider the following context-free grammar over the alphabet ∑ = {a, b, c} with S as the start symbol:
S → abScT | abcT
T → bT | b
Which one of the following represents the language generated by the above grammar?

Detailed Solution for Test: Context Free Grammar - Question 9

S → abScT
→ ababScTcT (∵ S → abScT)
→ abababcTcTcT (∵ S → abcT)
→ abababcbTcTcT (∵ T → bT)
→ abababcbbTcTcT (∵ T → bT)
→ abababcbbbTcTcT (∵ T → bT)
→ abababcbbbbcTcT (∵ T → b)
→ abababcbbbbcbcT (∵ T → b)
→ abababcbbbbcbcbT (∵ T → bT)
→ abababcbbbbcbcbb (∵ T → b)
abababcbbbbcbcbb = (ab)3cb4cbcb2
From this string, it is clear that all the option 1),3) and 4) are not generated by given grammar.

Test: Context Free Grammar - Question 10

Consider the following languages.
L1 = {wxyx | w, x, y ϵ (0 + 1)+}
L2 = {xy | x, y ϵ (a + b)*, |x| = |y|, x ≠ y}
Which one of the following is TRUE?

Detailed Solution for Test: Context Free Grammar - Question 10

Concept:
A language is regular if we could find a corresponding regular expression that generates it and an finite automata that accepts it. A language is CFL, if we could construct a Push Down Automata (PDA) that accepts it.
L1 = {wxyx | w, x, y ϵ (0 + 1)+}
L1 is a regular language.
Since it is given that w, x, y ϵ (0 + 1)+}, that means w, x, y all three can be strings of {0, 1}.
L1 can be generated by a regular expression of the form:
(0+1)+0 (0+1)+0 + (0+1)+1 (0+1)+1, by putting x as 0 and 1 alternatively. Since it can be represented as a regular expression, it is a regular language.
L2 = {xy | x, y ϵ (a + b)*, |x| = |y|, x ≠ y}
L2 is a Context Free Language.
L2 consists of set of strings which could be split into two non-identical substrings, but of equal length. Since comparison is involved, it cannot be done with a finite automata. However, a PDA can do comparisons, so PDA would accept the above language. Thus L2 is a CFL.

Information about Test: Context Free Grammar Page
In this test you can find the Exam questions for Test: Context Free Grammar solved & explained in the simplest way possible. Besides giving Questions and answers for Test: Context Free Grammar , EduRev gives you an ample number of Online tests for practice

Top Courses for Computer Science Engineering (CSE)

Download as PDF

Top Courses for Computer Science Engineering (CSE)