Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.
You're offline
Unit 3 MCQsFORMAL LANGUAGES
CSE322 ·
50 questions. Pick an option to check it.
What is the formal definition of a Grammar in Formal Language Theory?
Not quite. Try another option.
Answer:
A formal grammar is mathematically defined as a 4-tuple , where is a finite set of variables (non-terminals), is a finite set of terminals, is a set of production rules, and is the start symbol.
Question 2 of 50
In the grammar tuple , what does the intersection of and yield?
Not quite. Try another option.
Answer: An empty set ()
Variables (non-terminals) and terminals must be strictly disjoint sets. Therefore, their intersection is the empty set.
Question 3 of 50
Which mathematical notation correctly denotes the language generated by a grammar ?
Not quite. Try another option.
Answer:
The language generated by a grammar consists of all strings of purely terminal symbols () that can be derived from the start symbol in zero or more steps ().
Question 4 of 50
What is a 'derivation' in the context of formal grammars?
Not quite. Try another option.
Answer: A sequence of production rule applications replacing non-terminals to generate a string
A derivation is a sequence of steps where at each step, a variable (non-terminal) is replaced by the right side of one of its production rules until a string of terminals is formed.
Question 5 of 50
In a leftmost derivation, which non-terminal is replaced at each step?
Not quite. Try another option.
Answer: The leftmost non-terminal in the current sentential form
By definition, a leftmost derivation strictly replaces the leftmost non-terminal present in the sentential form at every step.
Question 6 of 50
What is a sentential form?
Not quite. Try another option.
Answer: Any string in that can be derived from the start symbol
If , then is a sentential form. It can contain a mix of both variables and terminals.
Question 7 of 50
According to the Chomsky Hierarchy, Type 0 grammars generate which class of languages?
Not quite. Try another option.
Answer: Recursively Enumerable Languages
Type 0 grammars are unrestricted grammars and they generate Recursively Enumerable (RE) languages, recognizable by Turing Machines.
Question 8 of 50
Which type of grammar corresponds to Context-Free Languages in the Chomsky Hierarchy?
Not quite. Try another option.
Answer: Type 2
Type 2 grammars are Context-Free Grammars (CFGs) and they generate Context-Free Languages (CFLs).
Question 9 of 50
What is the proper subset relation defining the Chomsky hierarchy, where denotes Type languages?
Not quite. Try another option.
Answer:
Regular languages () are a subset of Context-Free (), which are a subset of Context-Sensitive (), which are a subset of Recursively Enumerable ().
Question 10 of 50
What is the primary constraint on the production rules for a Type 1 (Context-Sensitive) grammar?
Not quite. Try another option.
Answer:
In Type 1 (Context-Sensitive) grammars, the length of the right-hand side string must be greater than or equal to the length of the left-hand side string, making them non-contracting.
Question 11 of 50
What is the only valid exception to the length-increasing rule () in a Context-Sensitive Grammar?
Not quite. Try another option.
Answer: is allowed provided does not appear on the right side of any production
To allow the language to contain the empty string , the start symbol may derive , but cannot appear on the right-hand side of any rule to preserve the non-contracting property for other strings.
Question 12 of 50
What is the defining constraint on the production rules of a Type 2 (Context-Free) grammar?
Not quite. Try another option.
Answer: The left-hand side must consist of exactly one non-terminal
In a Context-Free Grammar (), must be a single non-terminal (). The replacement is independent of the context.
Question 13 of 50
Which of the following describes the production rules for a Type 3 (Regular) grammar?
Not quite. Try another option.
Answer: Rules must be strictly either right-linear or strictly left-linear
Type 3 grammars (Regular Grammars) must be either purely right-linear (e.g., ) or purely left-linear (e.g., ). Mixing them results in a Linear Grammar, which is Context-Free but not necessarily regular.
Question 14 of 50
What is the only restriction on the production rules for a Type 0 (Unrestricted) grammar?
Not quite. Try another option.
Answer: must contain at least one non-terminal
In an unrestricted grammar, cannot be strictly empty or consist only of terminals; it must have at least one variable (non-terminal) to allow for substitution.
Question 15 of 50
Which computational model strictly corresponds to Recursively Enumerable (Type 0) languages?
Not quite. Try another option.
Answer: Turing Machine
Turing Machines are capable of recognizing Recursively Enumerable languages, which correspond to Type 0 (Unrestricted) grammars.
Question 16 of 50
Which computational model strictly corresponds to Context-Sensitive (Type 1) languages?
Not quite. Try another option.
Answer: Linear Bounded Automaton
Linear Bounded Automata (LBAs) are restricted Turing Machines where the tape head cannot move beyond the bounds of the input string. They recognize Context-Sensitive languages.
Question 17 of 50
Which computational model strictly corresponds to Context-Free (Type 2) languages?
Not quite. Try another option.
Answer: Pushdown Automaton
Pushdown Automata (PDAs) use a stack for memory and are the computational equivalent of Context-Free Grammars.
Question 18 of 50
Which computational model strictly corresponds to Regular (Type 3) languages?
Not quite. Try another option.
Answer: Finite Automaton
Finite Automata (both Deterministic and Non-Deterministic) recognize Regular Languages.
Question 19 of 50
By definition, a language is called 'Recursive' if:
Not quite. Try another option.
Answer: There exists a Turing Machine that halts on every input string, accepting if it is in and rejecting if it is not.
A Recursive language is a decidable language. A Turing Machine will always halt in an accept or reject state for any given input.
Question 20 of 50
By definition, a language is called 'Recursively Enumerable' (RE) if:
Not quite. Try another option.
Answer: There exists a Turing Machine that halts and accepts if a string is in , but may loop indefinitely if the string is not in .
For an RE language (semi-decidable), the Turing Machine is only guaranteed to halt and accept valid strings. For invalid strings, it may reject or run forever.
Question 21 of 50
Which of the following is true regarding the complement of a Recursive language?
Not quite. Try another option.
Answer: It is always Recursive.
Recursive languages are closed under complementation. If a TM always halts for , we can simply swap the accept and reject states to decide .
Question 22 of 50
What can be said about the complement of a Recursively Enumerable (RE) language that is NOT Recursive?
Not quite. Try another option.
Answer: It is not Recursively Enumerable.
If an RE language is not recursive, its complement cannot be RE. If it were RE, Post's Theorem dictates the language would be Recursive, creating a contradiction.
Question 23 of 50
What does Post's Theorem state regarding formal languages?
Not quite. Try another option.
Answer: If a language and its complement are both Recursively Enumerable, then is Recursive.
Post's Theorem establishes that a language is decidable (Recursive) if and only if both the language and its complement are semi-decidable (RE).
Question 24 of 50
How is the Halting Problem classified in formal language theory?
Not quite. Try another option.
Answer: It is Recursively Enumerable but not Recursive.
The Halting Problem is semi-decidable: we can simulate a TM to see if it halts (so it's RE). However, we cannot always determine if it will loop forever, making it undecidable (not Recursive).
Question 25 of 50
The intersection of a Context-Free Language (CFL) and a Regular Language is always:
Not quite. Try another option.
Answer: Context-Free
Context-Free Languages are closed under intersection with Regular Languages. The cross-product machine of a PDA and a DFA results in a new PDA.
Question 26 of 50
Are Context-Free Languages (CFLs) closed under intersection?
Not quite. Try another option.
Answer: No, the intersection of two CFLs is not necessarily a CFL.
CFLs are not closed under intersection. For example, and are CFLs, but their intersection is Context-Sensitive, not Context-Free.
Question 27 of 50
Which of the following describes the generic form of production rules in a Right-Linear Grammar?
Not quite. Try another option.
Answer: or (where is a terminal string)
In a right-linear grammar, all non-terminals must appear exclusively at the extreme right end of the right-hand side of a production rule.
Question 28 of 50
Which of the following describes the generic form of production rules in a Left-Linear Grammar?
Not quite. Try another option.
Answer: or (where is a terminal string)
In a left-linear grammar, all non-terminals must appear exclusively at the extreme left end of the right-hand side of a production rule.
Question 29 of 50
If a grammar freely mixes left-linear rules (e.g., ) and right-linear rules (e.g., ), what type of grammar is it?
Not quite. Try another option.
Answer: Linear Grammar
A grammar with at most one non-terminal on the right side of any rule is a Linear Grammar. Mixing left and right linearity generates Linear Languages, which are a subset of CFLs but not always Regular.
Question 30 of 50
Every valid Regular Grammar (either strictly right-linear or strictly left-linear) generates:
Not quite. Try another option.
Answer: A Regular Set (Regular Language)
Regular grammars are exactly the syntactic mechanism for generating Regular Sets, equivalent to Regular Expressions and Finite Automata.
Question 31 of 50
Which operation are Regular Languages NOT necessarily closed under?
Not quite. Try another option.
Answer: Infinite Union
Regular languages are closed under finite union. However, an infinite union of regular languages can yield a non-regular language (e.g., is Context-Free).
Question 32 of 50
Which right-linear regular grammar correctly generates the regular expression ?
Not quite. Try another option.
Answer:
The regular expression represents a choice between 'a' or 'b'. The grammar directly derives either 'a' or 'b'.
Question 33 of 50
Which right-linear regular grammar correctly generates the regular expression ?
Not quite. Try another option.
Answer:
The Kleene star operation allows zero or more occurrences of 'a'. generates multiple 'a's, and allows termination, including the empty string.
Question 34 of 50
Which right-linear regular grammar correctly generates the regular expression ?
Not quite. Try another option.
Answer:
To concatenate 'a' and 'b' sequentially in a right-linear grammar, 'a' transitions to a new non-terminal , which then generates the terminal 'b' and halts.
Question 35 of 50
Arden's Theorem is primarily utilized for which of the following purposes in Formal Language Theory?
Not quite. Try another option.
Answer: Converting a DFA or Regular Grammar into a Regular Expression
Arden's theorem is used to solve algebraic language equations derived from state transitions or grammar rules to find equivalent Regular Expressions.
Question 36 of 50
Arden's Theorem states that for sets , and , the equation has a unique solution provided what condition is met?
Not quite. Try another option.
Answer: does not contain the empty string
If does not contain , the recursive equation has strictly one unique regular expression solution.
Question 37 of 50
Under Arden's Theorem, if and does not contain , what is the unique solution for ?
Not quite. Try another option.
Answer:
Substitute into the equation: . Thus, is the correct solution. Note: This solves left-recursive equations.
Question 38 of 50
For the language equation (which arises from right-linear grammars), if does not contain , what is the unique solution for ?
Not quite. Try another option.
Answer:
Substitute into the equation: . This equation models right-linear rules , giving solution .
Question 39 of 50
Convert the right-linear grammar into an equivalent Regular Expression.
Not quite. Try another option.
Answer:
This grammar forms the equation (or where ). The derivation yields . The solution is .
Question 40 of 50
Convert the left-linear grammar into an equivalent Regular Expression.
Not quite. Try another option.
Answer:
This grammar forms the left-recursive equation . Using Arden's Theorem ( with ), the solution is .
Question 41 of 50
Find the regular expression for the right-linear grammar: , .
Not quite. Try another option.
Answer:
Substitute into . This gives . By solving , the unique solution is $__.
Question 42 of 50
Find the regular expression for the grammar: , .
Not quite. Try another option.
Answer:
From , we get . Substituting this into , we get (which is equivalent to ).
Question 43 of 50
Is every Context-Free Language also a Regular Language?
Not quite. Try another option.
Answer: No, Regular Languages are a strict subset of Context-Free Languages.
According to the Chomsky hierarchy, Type 3 (Regular) is a proper subset of Type 2 (Context-Free). Thus, not all CFLs are Regular (e.g., is CF but not Regular).
Question 44 of 50
Every Context-Free Language is also a:
Not quite. Try another option.
Answer: Context-Sensitive Language
The Chomsky Hierarchy indicates that Type 2 (Context-Free) is a proper subset of Type 1 (Context-Sensitive). Thus, every CFL is inherently Context-Sensitive.
Question 45 of 50
Which of the following languages is strictly Context-Free but NOT Regular?
Not quite. Try another option.
Answer:
requires matching counts of 'a' and 'b', which requires unbounded memory (a stack), so it cannot be regular, but it can be generated by a CFG.
Question 46 of 50
Which of the following languages is Context-Sensitive but NOT Context-Free?
Not quite. Try another option.
Answer:
The language requires tracking three dependent counts. A standard PDA (with one stack) cannot match all three, making it non-Context-Free. However, an LBA can track it, making it Context-Sensitive.
Question 47 of 50
Two formal languages and are said to be equivalent if and only if:
Not quite. Try another option.
Answer: They contain exactly the same set of strings ()
By set theory definition, two languages are equivalent if they are identical sets of strings, regardless of the grammar or automaton used to define them.
Question 48 of 50
Which of the following statements about the union of Recursive and Recursively Enumerable languages is TRUE?
Not quite. Try another option.
Answer: The union of two Recursive languages is always Recursive.
Recursive languages are closed under union. If TMs and decide and , we can build a TM that simulates both on input and accepts if either accepts; since both halt, the new TM also halts.
Question 49 of 50
What kind of grammar allows rules where the left-hand side can be any string containing at least one non-terminal, and the right-hand side can be shorter than the left-hand side?
Not quite. Try another option.
Answer: Type 0 (Unrestricted Grammar)
Only Type 0 (Unrestricted) grammars allow contracting rules (where ). Type 1 strictly prohibits this, requiring .
Question 50 of 50
Which automaton corresponds to a language formed by freely mixing left-linear and right-linear grammar rules (A Linear Grammar)?
A Linear Grammar generates a Linear Language, which is a proper subset of Context-Free Languages. Therefore, it is recognized by a Pushdown Automaton, specifically restricted to make at most one turn (transitioning from push to pop).
That's unit 3
Answer a few questions and your score shows up here.
Nearly through. Did unit 3 of CSE322 save you a night before the exam?
LPU Notes is free. A student pays for the servers.
Did unit 3 of CSE322 save you a night before the exam?
Then you can help keep it free for the next batch. Ads cover part of the server bill;
the rest comes out of a student's own pocket: the domain, the storage, and keeping
the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason.
to try again.