S -> a A c | a B d.
A -> z.
B -> z.
The test string can be azc.
Click for more about the above grammar, LR(0) Item Sets
The reason it's not LR(0) is that after reading the same token a, and same token z, you have two choices to reduce. (state 5)
But you can distinguish A and B by comparing the follow sets of A and B. where {c} for A and {d} for B.
S -> a A c | a B d | B c.
A -> z.
B -> z.
The test string can be azc.
Click for more about the above grammar
It's not SLR(1) since the follow set of B also includes c.
But you can trace the path of DFA to further examine the follow set. This is why LR(1) is more flexible when conflicts occur. It's a little hard to understand. It's helpful to see the DFA of both SLR:
and LR:
S -> a A c | a B d | b A | b B c.
A -> z.
B -> z.
The test string can be azc.
Click for more about the above grammar
If you know the procedure to get LALR. You can see that, in the DFA of LR(1):
state 9 and state 6 can be merged. That's why production S -> a A c | a B d | b A | b B part is introduced (not adding the last c).
It leads to a similiar state with same core as in SLR(1) DFA. As long as .A and .B is in the same state, it will lead to state 9 and state 6. After the merge, we got the DFA of LALR(1):
Now, we add the trailing c to the production S -> a A c | a B d | b A | b B c, after the merge, both the follow set of A_8 and B_8 contains c. Thus it has reduce-reduce conflicts.
S -> a A c | a B c d.
A -> z.
B -> z.
The test string can be azc. This one is trivial.
Thank you