Formal Languages and Grammars
This quiz is designed to assess your understanding of formal languages and grammars, which are fundamental concepts in computer science and linguistics.
Questions
What is a formal language?
- A set of strings that can be generated by a grammar
- A set of strings that can be recognized by a finite automaton
- A set of strings that can be parsed by a context-free grammar
- A set of strings that can be translated by a compiler
What is the Chomsky hierarchy?
- A classification of formal languages based on their generative power
- A classification of formal languages based on their recognition power
- A classification of formal languages based on their parsing power
- A classification of formal languages based on their translation power
Which of the following is not a type of formal grammar?
- Regular grammar
- Context-free grammar
- Context-sensitive grammar
- Unrestricted grammar
What is the difference between a regular grammar and a context-free grammar?
- Regular grammars can generate only finite languages, while context-free grammars can generate infinite languages.
- Regular grammars can generate only regular languages, while context-free grammars can generate context-free languages.
- Regular grammars can generate only context-free languages, while context-free grammars can generate context-sensitive languages.
- Regular grammars can generate only context-sensitive languages, while context-free grammars can generate unrestricted languages.
What is the pumping lemma for regular languages?
- For any regular language L, there exists a constant n such that every string in L of length at least n can be pumped.
- For any regular language L, there exists a constant n such that every string in L of length at least n can be pumped twice.
- For any regular language L, there exists a constant n such that every string in L of length at least n can be pumped three times.
- For any regular language L, there exists a constant n such that every string in L of length at least n can be pumped four times.
What is the Chomsky-Schützenberger theorem?
- Every context-free language is a regular language.
- Every regular language is a context-free language.
- Every context-free language is a context-sensitive language.
- Every context-sensitive language is an unrestricted language.
What is the difference between a context-sensitive grammar and an unrestricted grammar?
- Context-sensitive grammars can generate only context-sensitive languages, while unrestricted grammars can generate unrestricted languages.
- Context-sensitive grammars can generate only unrestricted languages, while unrestricted grammars can generate context-sensitive languages.
- Context-sensitive grammars can generate only context-free languages, while unrestricted grammars can generate context-sensitive languages.
- Context-sensitive grammars can generate only regular languages, while unrestricted grammars can generate context-free languages.
What is the Greibach normal form for context-free grammars?
- A context-free grammar in which every production rule is of the form A -> aB or A -> a
- A context-free grammar in which every production rule is of the form A -> BC or A -> a
- A context-free grammar in which every production rule is of the form A -> aBC or A -> a
- A context-free grammar in which every production rule is of the form A -> BC or A -> aB
What is the Cocke-Younger-Kasami algorithm?
- An algorithm for parsing context-free grammars
- An algorithm for generating context-free grammars
- An algorithm for recognizing context-free grammars
- An algorithm for translating context-free grammars
What is the Earley algorithm?
- An algorithm for parsing context-free grammars
- An algorithm for generating context-free grammars
- An algorithm for recognizing context-free grammars
- An algorithm for translating context-free grammars
What is the difference between a deterministic context-free grammar and a non-deterministic context-free grammar?
- Deterministic context-free grammars can generate only deterministic languages, while non-deterministic context-free grammars can generate non-deterministic languages.
- Deterministic context-free grammars can generate only non-deterministic languages, while non-deterministic context-free grammars can generate deterministic languages.
- Deterministic context-free grammars can generate only context-free languages, while non-deterministic context-free grammars can generate context-sensitive languages.
- Deterministic context-free grammars can generate only context-sensitive languages, while non-deterministic context-free grammars can generate unrestricted languages.
What is the CYK algorithm?
- An algorithm for parsing context-free grammars
- An algorithm for generating context-free grammars
- An algorithm for recognizing context-free grammars
- An algorithm for translating context-free grammars
What is the difference between a regular expression and a context-free grammar?
- Regular expressions can generate only regular languages, while context-free grammars can generate context-free languages.
- Regular expressions can generate only context-free languages, while context-free grammars can generate regular languages.
- Regular expressions can generate only context-sensitive languages, while context-free grammars can generate unrestricted languages.
- Regular expressions can generate only unrestricted languages, while context-free grammars can generate context-sensitive languages.
What is the Myhill-Nerode theorem?
- A theorem that states that every regular language is a deterministic language.
- A theorem that states that every context-free language is a deterministic language.
- A theorem that states that every context-sensitive language is a deterministic language.
- A theorem that states that every unrestricted language is a deterministic language.
What is the Kleene star operation?
- An operation that concatenates two strings together.
- An operation that repeats a string any number of times.
- An operation that reverses a string.
- An operation that complements a string.