Derivation and parse tree for aabb

December 4, 2026 · Team EasyExamNotes · 1 min read (est.) · 0 comments

Share on WhatsApp

← RGPV CS-501 Theory of Computation December 2025 Solved Question Paper

Question

For S→aSb | ab, derive aabb and draw its parse tree.

Asked in: CS-501 | December 2025 | 4(b)

Answer

Start with S and apply the recursive production once, then the terminating production.

  1. S⇒aSb using S→aSb.
  2. aSb⇒a(ab)b=aabb using S→ab.

There is only one variable at each step, so the leftmost and rightmost derivations coincide. In the parse tree, the root S has ordered children a,S,b; the inner S has children a,b. The leaf sequence is a,a,b,b.

Verification

The base production yields ab. Each recursive production adds one a at the left and one b at the right. Consequently the grammar generates exactly {aⁿbⁿ | n≥1}. The target word has n=2, so exactly one recursive step and one base step are necessary. The empty word is not generated. This also shows that the derivation for aabb is unique.

Derivation and parse tree for aabb diagram
Derivation and parse tree for aabb — original illustration

← RGPV CS-501 Theory of Computation December 2025 Solved Question Paper

Discussion

Ask a question, share your thoughts or report an error.

Sign in to participate in the discussion.

Join the discussion