• edited by
14,484 views
53 53 votes

Consider the following decision problems:

$(P1):$ Does a given finite state machine accept a given string?

$(P2):$ Does a given context free grammar generate an infinite number of strings?

Which of the following statements is true?

  1. Both$(P1)$ and $(P2)$ are decidable
  2. Neither $(P1)$ nor $(P2)$ is decidable
  3. Only $(P1)$ is decidable
  4. Only $(P2)$ is decidable

2 Answers

Best answer
48 48 votes

For $P1$, we just need to give a run on the machine. Finite state machines always halts unlike TM.

For$ P2$, check if the $CFG$ generates any string of length between $n$ and $2n-1$, where $n$ is the pumping lemma constant. If So, $L(CFG)$ is infinite, else finite. Finding the pumping lemma constant is not trivial - but there are other procedures which can do this - http://cs.stackexchange.com/questions/52507/is-it-decidable-whether-a-given-context-free-grammar-generates-an-infinite-numbe/52520

Hence, both $P1$ and $P2$ are decidable - answer is (A).

http://gatecse.in/wiki/Grammar:_Decidable_and_Undecidable_Problems

• edited by
Answer:
Position:
Show:

Related questions

51 51 votes
8 answers 8 answers
17.5k
17.5k views
Kathleen asked Sep 14, 2014
17,513 views
A multiset is an unordered collection of elements where elements may repeat any number of times. The size of a multiset is the number of elements in it, counting repetiti...
2 2 votes
2 2 answers
3.3k
3.3k views
Kathleen asked Sep 14, 2014
3,296 views
The 8085 microprocessor responds to the presence of an interruptas soon as the TRAP pin becomes 'high'by checking the TRAP pin for 'high' status at the end of each instru...
106 106 votes
7 answers 7 answers
29.2k
29.2k views
Daggerhunt asked Nov 16, 2014
29,176 views
Let $G$ be an undirected graph. Consider a depth-first traversal of $G$, and let $T$ be the resulting depth-first search tree. Let $u$ be a vertex in $G$ and let $v$ be t...
88 88 votes
9 answers 9 answers
28.6k
28.6k views
Kathleen asked Sep 14, 2014
28,623 views
In SQL, relations can contain null values, and comparisons with null values are treated as unknown. Suppose all comparisons with a null value are treated as false. Which ...