Consider the canonical πΏπ
(0) parsing of the grammar below using terminals
{π, π, π} and non-terminals {π΄, π΅, πΆ, π} with π as the start symbol.
πβπ΄πΆπ΅
π΄βππ΄ | π
πΆβππΆ | π
π΅βππ΅ | π
Which one of the following options gives the number of shift-reduce conflicts that
will occur in the πΏπ
(0) ACTION table?
We must build the canonical LR(0) collection for the augmented grammar and count how many states contain both a shift item and a reduce item on the same terminal.
Step 1: Augmented grammar
\[S' \to S,\quad S \to ACB,\quad A \to aA \mid \epsilon,\quad C \to cC \mid \epsilon,\quad B \to bB \mid b\]Step 2: Construct \(I_0 = closure(\{S' \to \cdot S\})\)
\[I_0 = \{\, S' \to \cdot S,\; S \to \cdot ACB,\; A \to \cdot aA,\; A \to \cdot \,\}\]Since \(A \to \epsilon\) is a complete item (dot at end) sitting in the same state as the shift item \(A \to \cdot aA\) (which shifts on 'a'), \(I_0\) has a shift/reduce conflict on 'a'.
Step 3: GOTO(\(I_0\), A) = \(I_1\)
\[I_1 = \{\, S \to A \cdot CB,\; C \to \cdot cC,\; C \to \cdot \,\}\]Again the reduce item \(C \to \cdot\) coexists with the shift item \(C \to \cdot cC\) (shift on 'c'). Conflict on 'c' in \(I_1\).
Step 4: GOTO(\(I_0\), a) = \(I_2\)
\[I_2 = \{\, A \to a \cdot A,\; A \to \cdot aA,\; A \to \cdot \,\}\]Same pattern: shift on 'a' versus reduce \(A \to \cdot\). Conflict on 'a' in \(I_2\).
Step 5: GOTO(\(I_1\), c) = \(I_4\)
\[I_4 = \{\, C \to c \cdot C,\; C \to \cdot cC,\; C \to \cdot \,\}\]Shift on 'c' versus reduce \(C \to \cdot\). Conflict on 'c' in \(I_4\).
Step 6: GOTO(\(I_1\), C) = \(I_3\) then GOTO(\(I_3\), b) = \(I_7\)
\[I_3 = \{\, S \to AC \cdot B,\; B \to \cdot bB,\; B \to \cdot b\,\}\]\[I_7 = \{\, B \to b \cdot B,\; B \to b \cdot,\; B \to \cdot bB,\; B \to \cdot b \,\}\]Here \(B \to b \cdot\) is a completed reduce item while \(B \to b \cdot B\) (via \(B \to \cdot bB\)) requires a shift on 'b'. Conflict on 'b' in \(I_7\).
Step 7: Tally the conflicting states
The states carrying a genuine shift/reduce clash are \(I_0\) (on a), \(I_1\) (on c), \(I_2\) (on a), \(I_4\) (on c), and \(I_7\) (on b). Every other completed state (such as \(I_5: A \to aA \cdot\), \(I_6: S \to ACB \cdot\), \(I_8: C \to cC \cdot\), \(I_9: B \to bB \cdot\)) is a pure reduce state with no competing shift, so it adds no conflict.
Step 8: Count
Total shift-reduce conflicts \(= 5\).
Final Answer:
\[\boxed{5 \text{ (Option D)}}\]A schedule of three database transactions \(T_1\), \(T_2\), and \(T_3\) is shown. \(R_i(A)\) and \(W_i(A)\) denote read and write of data item A by transaction \(T_i\), \(i = 1, 2, 3\). The transaction \(T_1\) aborts at the end. Which other transaction(s) will be required to be rolled back?

A lexical analyzer uses the following token definitions
ο· πππ‘π‘ππβ[π΄βππβπ§]
ο· πππππ‘β[0 β9]
ο· ππβπππ‘π‘ππ (πππ‘π‘ππ | πππππ‘)*
ο· ππ’ππππβπππππ‘+
ο· π€π β(πππππ | π‘ππ | πππ€ππππ)+
For the string given below,
π₯1 23ππ 78 π¦ 7π§ π§π§5 14π΄ 8π» π΄ππππ·
the number of tokens (excluding π€π ) that will be produced by the lexical analyzer
is __________. (answer in integer)
Consider the following two syntax-directed definitions SDD1 and SDD2 for type
declarations.
π· is the start symbol, and πππ‘, πππππ‘ and ππ are the three terminals. The non-terminal
π1 is the same as π and the non-terminal π·1 is the same as π·. Here, the subscript is
used to differentiate the grammar symbols on the two sides of a production. The
function ππ’π‘ updates the symbol table with the type information for an identifier.
Let P and Q be the languages specified by grammars G1 and G2, respectively.
Which of the following statements is/are true?
SDD1
Grammar
(G1)
Semantic Rules
π· βπ π
π·. π‘π¦ππ = π. π‘π¦ππ
π. π‘π¦ππ = π. π‘π¦ππ
π β πππ‘
π. π‘π¦ππ = πππ‘
π β πππππ‘
π. π‘π¦ππ = πππππ‘
πβπ1 ππ
π1. π‘π¦ππ= π. π‘π¦ππ
ππ’π‘(ππ. πππ‘ππ¦, π. π‘π¦ππ)
π β ππ
ππ’π‘(ππ. πππ‘ππ¦, π. π‘π¦ππ)
SDD2
Grammar
(G2)
Semantic Rules
π·βπ·1 ππ
π·. π‘π¦ππ= π·1. π‘π¦ππ
ππ’π‘(ππ. πππ‘ππ¦, π·1. π‘π¦ππ)
π· β π ππ
π·. π‘π¦ππ = π. π‘π¦ππ
ππ’π‘(ππ. πππ‘ππ¦, π. π‘π¦ππ)
π βπππ‘
π. π‘π¦ππ = πππ‘
π β πππππ‘
π. π‘π¦ππ = πππππ‘