logo

AQA A-Level Computer Science practice

Explain why the language of balanced parentheses with arbitrary nesting can be described using BNF but cannot be represented using a regular expression. Include a suitable recursive production rule and explain its role.

Try the question first, then check the answer and practise the same topic again.

At a glance

Question

Type

practice

Style

Topic

Context-free languages

Exam-style question

Try this first

Explain why the language of balanced parentheses with arbitrary nesting can be described using BNF but cannot be represented using a regular expression. Include a suitable recursive production rule and explain its role.

Answer and explanation

Concise answer

A suitable rule is <S> ::= "(" <S> ")" <S> | empty.

Why this is correct

A strong answer identifies recursion as the important feature of BNF and connects it to unlimited nesting. It should also explain that the empty alternative terminates the recursive process and that regular expressions cannot represent this complete language.

Use the concise answer above for a quick check, then reveal the full model answer and detailed explanation.

Common mistake

No common mistake is linked to this question yet.

Related flashcards

No flashcards are published for this page yet.

Related practice questions