Discrete Structures Exam 2

Ace your homework & exams now with Quizwiz!

Type ____ Grammars are recognized bt Linear Bound Automata

1

The following rules describe a type ____ grammar: Type 1 and LHS of production can only have 1 variable

2

Type ___ grammars are recognized by Nondeterministic Pushdown Automata

2

What type of grammar can only have 1 variable on the left hand side of a production?

2

What type of grammar is the following? S->AB A->a B->b

2

FSAs can be used to recognize type ___ grammars

3

The following rules describe what type of grammar? α->β where α is (V + T)**V(V + T)** β is (V + T)** Where V is a variable and T is a terminal

Type 0

What type of grammar is the following? Sab-> A->S

Type 0

What type of grammar is the following? S->AB AB->abc B->b

Type 1

What Type of grammar must be type 0 AND in the form of α->β where |α|<=|β|

Type 1(Context Sensitive)

The production grammar {S -> aSbb | abb} is

Type 2 grammar

What type of grammar is the following? S->ab

Type 3

Which of the following properties are context-free languages closed under? Intersection Concatenation Complement Union Kleene Star

Union, Kleene Star, Concatenation

Place the following types of grammar in order based on Chomsky's Hierarchy of Grammar Regular Languages Context Free Unrestricted Context Sensitive

Unrestricted Context Sensitive Context Free Regular Languages

What type of grammar is considered type 0?

Unrestricted grammars

A Pushdown Automata is _________ if there is at most one transition applicable to each configuration? a) deterministic b) Nondeterministic c) Finite d) Non Finite

a

A context-sensitive grammar (CSG) is a) a formal grammar in which the left-hand sides and right-hand sides of any production rules may be surrounded by a context of terminal and non-terminal symbols b) is an unrestricted grammar c) no more general than context free grammar d) one that does not allow S-> λ

a

Assume the statements S1 and S2 are given as: S1: Given a context free grammar G, there exists an algorithm for determining whether L(G) is infinite S2: There exists and algorithm to determine whether two context free grammars generate the same language Which of the following is true? a) S1 is correct and S2 is not correct b) Both S1 and S2 are correct c) Both S1 and S2 are not correct d) S1 is not correct and S2 is correct

a

Grammar that produce more than one Parse tree for the same string is a) ambiguous b) Unambiguous c) Complementation d) Concatenation Intersection

a

If every string of a language can be determined whether it is legal or illegal in finite time the language is called a) Decidable b) undecideable c) Interpretive d) non deterministic

a

The classic example of a non-context-free language whose complement is context-free is a) {ww | w ∈ {a,b}*} is not a CFL but its complemnt is b) no such example c)The complement of a non-context-free language is always not context free d)The complement of a context free language is always not context free

a

The following grammar S->bS | b is a a) type-3 grammar b) type-2 grammar c) type-1 grammar d) type-0 grammar

a

Which of the following is not true? a) CFLs are not closed under substitution and homomorphism b)CFLs are not closed under intersection c) CFLs are not closed under complement d) CFLs are not closed under max or min

a

Which string can be produced by S->aS | bA, A->d | ccA? a)aabccd b)adabcca c)abcca d)abababd

a)aabccd

Definition of a language L with alphabet {a} is given as follwing. L = {a^nk | k >0, and n is positive integer constant} What is the minimum number of states needed in a DFA to recognize L? a) k+1 b) n+1 c) 2n+1 d) 2k+1

b

S-> aSa | bSb | a | b The language generated by the above grammar over the alphabet {a,b} is the set of a) all palindromes b) All odd length palindromes c) Strings that begin and end with the same symbol d) All even length palindromes

b

The idea of an automaton with a stack as auxiliary storage... a) Finite Automata b) Push down Automata c) Deterministic Automata d) None of these

b

Which of the following is the most general phase structured grammar? a) Regular b) Context sensitive c) Context free d) None of the above

b

Which of the following is undecidable? a) Membership problem of CFG b) ambiguity problem for CFG c)Finiteness problem for FSA d)Equivalence problem for FSA

b

All strings having equal number of a and b can be recognized by a) DFA b) NDFA c) PDA d) All of the above

c

Choose the correct statements a)All languages can be generated by CFG b)Any regular language has an equivalent CFG c)Some non-regular languages can't be generated by a CFG d) Some regular languages can't be generated by nay CFG

c

Consider the language L1, L2, and L3 as give below L1 = {0^p 1^q | p,q ∈ N) L2 = {0^p 1^q | p,q ∈ N and p = q) L3 = {0^p 1^q 0^r | p,q,r ∈ N and p=q=r) Which of the following statements is not true? a) PDA can be used to recognize L1 and L2 b) L1 is a regular language c) All 3 languages are context free d) Turing machine can be used to recognize all 3 languages

c

Let L(G) denote the language generated by the grammar G. To prove set A = L(G) a) it is enough to prove that an arbitrary member of A can be generated by grammar G b) it is enough to prove that an arbitrary string generated by G, belongs to set A c) both the above comments (a) and (b) are to be proved d)either of the above comments (a) or (b) is to be proved

c

Let P be a regular language and Q be context-free language such that Q is a proper subset of P (ex. let P be the language represented by the regular expression p*q* and Q be (p^n 1^n | n ∈ N)) Then which of the following is ALWAYS regular? a) P ∩ Q b) P - Q c) Σ* - P d) Σ* - Q

c

Pushdown Automata represents a a) type 0 grammar b) type 1 grammar c) type 2 grammar d) type 3 grammar

c

The Union of CFL and regular languages a) is always regular b) is always context free c) both a and b d) need not be regular

c

Which of the following CFG's can't be simulated by an FSM? a) S-> Sa | a b) S-> abX X-> cY Y-> d | aX c) S-> aSb | ab d) none of the above

c

Which of the following conversions is not possible algorithmically? a) regular grammar to context-free grammar b)nondeterministic FSA to deterministic FSA c)nondeterministic PDA to deterministic PDA d) nondeterministic TM to deterministic TM

c

Which of the following is most powerful? a) DFA b) NDFA c) 2PDA d) DPDA

c

Which of the following statements is false? a) Context-free languages are closed under union b) Context-free languages are closed under concatenation c) Context-free languages are closed under intersection d) Context-free languages are closed under Kleene closure

c

A context free language can be recognized by a) Finite State Automaton b) Linear Bound Automaton c) Pushdown Automaton d) both B and C

d

CSG can be recognized by a) FSM b) DPDM c) NDPDM d) linearly bounded memory machine

d

Choose the correct statements a) An FSM with 1 stack is more powerful than an FSM with no stack b) an FSM with 2 stacks is more powerful than an FSM with 1 stack c) an FSM with 3 stacks is more powerful than an FSM with 2 stacks d) All of the above

d

Let L = L1 ∩ L2, where L1 and L2 are languages defined by L1 = {a^m b^m ca^n b^n |m,n >= 0} L2 = {a^i b^j c^k | i,j,k >=0} Then L is a) not recursive b) Regular c) Context free but not regular d)Recursively enumerable but not context free

d

The following CFG S->aS | bS | a | b is equivalent to the expression a) (a** + b)** b) (a + b)* c) (a+b)(a+b)^+ d) (a+b)*(a+b)

d

The union of a context-free language and a regular language a) need not be regular b) need not be context-free c) is always regular but is not always context -free d) is always regular and context-free

d

Which of the following are not decidable? a) is w in L b) is L empty c) is L finite? d) is CFG ambiguous?

d

Which of the following does not belong to context-free grammars? a) Terminal symbol b) Non-terminal symbol c) start-symbol d) end symbol

d

Which of the following statements is wrong? a) The regular sets are closed under intersection b) The class of regular sets is closed under substitution C) The class of regular sets is closed under homomorphism d)Context Sensitive Grammar(CSG) can be recognized by FSM

d

Which one of the following is false? a)There is a unique minimal DFA for every regular language b) Every NFA can be converted to an equivalent PDA c) Complement of every context-free language is recursive d)Every nondeterministic PDA can be converted to an equivalent deterministic PDA

d

What Type of grammar is described by the following rules? V->VT** / T** or V->T**V / T** Where V = Variable, T = Terminal

type 3

The following CFG S->aB | bA A->a | as | bAA B-> b | bs | aBB generates strings of terminals that have a) Odd number of a's and odd number of b's b) Even number of a's and even number of b's c) Equal number of a's and b's d) Innequal number of a's and b's

C

What type of grammar is considered type 2?

Context Free Grammar

What type of grammar is considered type 1?

Context Sensitive Grammars

Any string of terminals that can be generated by the following CFG S->XY X->aX | bX | a Y-> Ya | Yb | a a) has at least one b b) should end in an 'a' c) has no consecutive a's or b's d) has at least two a's

D

Solvable CFL Problems: How can we decide if: Is L finite(infinite)

Reduce G Run DFS If no loops then finite

Solvable CFL Problems: How can we decide if: Is L empty (non-empty)?

Reduce G, If no rules left then empty

What type of grammar is considered type 3?

Regular Grammars

What are the steps, in order to convert a CFG to CNF?

Remove Lambda/Epsilon Rules Remove Unit Rules Remove Non-productive Symbols Remove Unreachable Symbols Reduce to CFG

Solvable CFL Problems: How can we decide if: w is in L?

Run CKY. If S is in the final cell then w exists in L

Give a production grammar for the language L = {x | x ∈ (a,v)*, the number of a's in x is a multiple of 3}

S -> bS | b | aA | bA A -> aB B -> bB B -> aS


Related study sets

Cancer of the Kidney, Renal Pelvis, and Ureter

View Set

The GLB ACT - The Gramm-Leach-Bliley Act (Regulation P)

View Set

BIO 31 Exam II Study Set Cuellar

View Set

علوم - الحركة والزخم + القوة وقوانين نيوتن

View Set

Chapter 20 Nursing Management Pregnancy at Risk: Health Conditions & Vulnerable Populations

View Set

HIS 102 Western Civ Kevin Windham Exam One

View Set

Leadership and Personal Development Final Exam

View Set

N201 OB: Pregnancy, Labor, Childbirth, Postpartum- Uncomplicated

View Set