Grammar and Context Free Grammars

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Suppose the alphabet Σ = {a, b}, and suppose the grammar is S → λ | aS | bS. Which of the following is a correct description of the language specified?

Any string consisting of a's and b's, including the empty string - Or - All strings over Σ - Or - Any combination of a's and b's including the empty string

Let Σ = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, and N, the set of nonterminals, be {D, E}, with E being the start symbol, and the productions are D → digit, which is shorthand for the 10 productions D → 0, D →1, and so on E → D, E → ED. Which of the following strings could occur in a derivation?

EDD - Or - 000

Consider the following grammar Id resolves to an identifier, which is a string of letters and numbers beginning with a letter. The symbols used stand for logical and, logical or, illogical, and implies. The double arrow is used to avoid confusion with the arrow used in productions. Which of the following can be generated by this grammar?

A ^ BA

Consider the design of the following grammar to specify addition facts: S → L = Number Possibility 1: L → Number | L + L Possibility 2: L → Number | L + Number Possibility 3: L → Number | Number + L To avoid introducing all the complexity of having the grammar define a number, the non-terminal number can be expanded informally by replacing it with a signed integer, such as 49, 0, or -7. Which of the following statement is true?

All three choices generate the same language

In a recursion, suppose context free grammar G has a non-terminal N, and a sequence of productions that starting from N yields a string containing N. In this case, the grammar is recursive. Suppose the grammar includes the given productions: N → bR R → cN Starting with N, the following derivation is possible: N → bR → bcN. Thus, the grammar is seen to be recursive. Write N →→ αNβ to indicate that the string αNβ can be derived from N. This is nontrivial if one of α or β has nonzero length. Which of the following is true, assuming that the grammar is context free?

If the grammar is recursive, and has a derivation N →→ αNβ where at least one of α or β has nonzero length then the grammar will generate an infinite number of strings - Or - If the language generated by the grammar G is finite, then the grammar contains no nontrivial recursions

Suppose Σ = {a, b} and you have the given data of two grammars G1 and G2, and corresponding languages L1 and L2: G1 has productions S → aaS | bbS | λ, where S is the start symbol. G2 has productions T → abT | baT | λ, where T is the start symbol. You can combine G1 and G2 into a new grammar that contains all the productions that are either in G1 or G1 and adding a new start symbol R and the productions R → S | T. Which is a valid description of the language L generated by G

L1 U L2

The given items have all the components of a formal grammar, with some of the labels missing. Identify the start symbol.

Omega

The given items have all the components of a formal grammar, with some of the labels missing. Identify one of the productions.

Omega > aBOmegac Omega > abc Ba > aB Bb > bb

Suppose that you have a finite state machine M with states T1 (the start state), T2 ,... Tn, and an input alphabet Σ, and accepting states U1 ,..., Uk. When M is in state T and receives input a, it will move to some state U; this transition will be written as TaU. Which of the following grammar will generate the language accepted by M?

The non-terminals correspond to all subsets of machine states. If the subset has states T1, T2, ... Tk, and input a causes these states to transition to U1, U2, ..., Uk and if the non-terminal T represents the set { T1, T2, ... Tk } and U represents { U1, U2, ..., Uk }, then add the production T → aU. If a non-terminal T represents a set containing an accepting state, add T → λ. The start symbol is the non-terminal corresponding to the set {S}, where S is the machine start state. - Or - The non-terminals N correspond to the states. The start symbol corresponds to T1, and for each transition TaU, you have a production T → aU, and for each accepting state T, there is a transition T → λ.

The following distributive law is a (b + c) = a × b + a × c, where a, b, and c are variables: D → L = R L → Id (Id + Id ) R → Id × Id + Id × Id Id = Letter | Letter Id Letter = a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z Which of the following can be generated by this grammar?

a (b + c) = a × b + a × c - Or - alpha (beta + gamma) = beta × alpha + gamma × alpha

Which of the given string is generated by the following grammar? S → aA A → bB B → aC C → bbD D → λ D → S

ababb

Which of the following strings will the following grammar generate? S → Bb | Ca B → Db | Ea D → Sa | a E → Sb | b C → bb | Sbb

abb - Or- abbbba

Which of the following strings will the following grammar generate? S → bA | aB A → a | aS B → b | bS

baba - Or - ab - Or - baab

Let Σ = {a, b, c}, and the productions S → aSa, S → bSb, S → cSc, S → aa, S → bb, and S → cc. Which of the following strings is in the language generated by this grammar?

bccbaabccb

The given items have all the components of a formal grammar, with some of the labels missing. Identify the non-terminals.

{Omega, B}

The given items have all the components of a formal grammar, with some of the labels missing. Identify the alphabet.

{a, b, c}

Below is a simplified grammar for specifying expressions E → ( E ) | T + E | T - E | T T → F * T | F / T | F F → Id | ( E ) Id → letter | letter Id letter → a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p | q | r | s | t | u | v | w | x | y | z This grammar doesn't allow for unary minus, for example -x. Suppose to fix this omission the production E → - E is added. Which of the following can be generated?

x*y - -x*y - Or -

Suppose Σ = {a, b} and you have two given grammars, G1 and G2: G1 has productions S → aaS | bbS | λ, where S is the start symbol. G2 has productions T → abT | baT | λ, where T is the start symbol. You can combine G1 and G2 into a new grammar that contains all the productions that are either in G1 or G1 and adding a new start symbol R and the productions R → S | T. Which of the following strings can G generate?

λ


संबंधित स्टडी सेट्स

Salesforce.com ADM 201 Study Guide - Practice 1

View Set

A&P Chapter 19 Heart & Cardiovascular Function

View Set

4B - SHERPATH - CHAP. 43 - care of the pt with a integumentary disorder - 10/7/22

View Set

Honors Science Worksheet 5-56 Structure of a Typical Flower

View Set

BJU Economics Chapter 6 - Economic Systems (control civilizations)

View Set

Radha Appan ISQS 4348 Exam 1 review

View Set