retagged by
7,851 views
10 votes
10 votes

Consider the following statements.

  • $S_1:$ Every $\text{SLR(1)}$ grammar is unambiguous but there are certain unambiguous grammars that are not $\text{SLR(1)}$.
  • $S_2:$ For any context-free grammar, there is a parser that takes at most $O(n^3)$ time to parse a string of length $n$.

Which one of the following options is correct?

  1. $S_1$ is true and $S_2$ is false
  2. $S_1$ is false and $S_2$ is true
  3. $S_1$ is true and $S_2$ is true
  4. $S_1$ is false and $S_2$ is false
retagged by

2 Answers

Best answer
19 votes
19 votes

Correct option is C.  Both statements are correct.

An unambiguous grammar is not necessarily $\text{SLR}(1).$ But every $\text{SLR}(1)$ grammar is unambiguous.

We do have $\text{CYK}$ algorithm which takes $O(n^3)$ time (assuming size of the context-free grammar $|G|$ to be a constant) to parse any string of length $n$ using a context-free grammar $G.$

edited by
Answer:

Related questions

13 votes
13 votes
2 answers
2
Arjun asked Feb 18, 2021
6,393 views
Consider the following context-free grammar where the set of terminals is $\{a,b,c,d,f\}$. $$\begin{array}{lll} \text{S} & \rightarrow & d \: a \: \text{T} \mid \text{R} ...
12 votes
12 votes
4 answers
3
6 votes
6 votes
1 answer
4
Arjun asked Feb 18, 2021
2,778 views
___________ is to surgery as writer is to ___________Which one of the following options maintains a similar logical relation in the above sentence?Plan, outlineHospital, ...