// Answer to Question 1
// a) Compute First and Follow sets for all non-terminals
// Grammar G:
// S -> W | XY
// W -> ZY | ε
// X -> c | a
// Y -> xb | d
// Z -> Xb | ε
// First Sets:
First(S) = { a, c, x, d, ε }
First(W) = { a, c, x, d, ε }
First(X) = { a, c }
First(Y) = { x, d }
First(Z) = { a, c, ε }
// Follow Sets:
Follow(S) = { $ }
Follow(W) = { $ }
Follow(X) = { x, d, b }
Follow(Y) = { $ }
Follow(Z) = { x, d }
// b) LL(1) Parsing Table
// Terminals: a, b, c, d, x, $
// Non-terminals: S, W, X, Y, Z
// Parsing Table:
// | a | b | c | d | x | $ |
// -------------------------------------------------------------------------------------
// S | S -> W | | S -> W | S -> W | S -> W | S -> W |
// | S -> XY | | S -> XY | S -> XY | S -> XY | |
// -------------------------------------------------------------------------------------
// W | W -> ZY | | W -> ZY | W -> ZY | W -> ZY | W -> ε |
// -------------------------------------------------------------------------------------
// X | X -> a | | X -> c | | | |
// -------------------------------------------------------------------------------------
// Y | | | | Y -> d | Y -> xb | Y -> d |
// -------------------------------------------------------------------------------------
// Z | Z -> Xb | | Z -> Xb | Z -> Xb | Z -> Xb | Z -> ε |
// -------------------------------------------------------------------------------------
// Explanation:
// - For non-terminal S, both productions S -> W and S -> XY have overlapping First sets {a, c}.
// - This leads to multiple entries for terminals 'a' and 'c' in the S row of the parsing table.
// - Such conflicts violate the LL(1) condition, which requires at most one production per cell.
// Conclusion:
// The grammar G is **not LL(1)** due to conflicts in the parsing table for non-terminal S with terminals 'a' and 'c'.