10,287 views

In some programming language, an identifier is permitted to be a letter followed by any number of letters or digits. If $L$ and $D$ denote the sets of letters and digits respectively, which of the following expressions defines an identifier?

1. $(L + D)^+$
2. $(L.D)^*$
3. $L(L + D)^*$
4. $L(L.D)^*$

edited
from [D] we can not generate letter followed by letters only or letter followed by digits.
a letter followed by( any number of( letters or digits)*).

Correct Option: C

It has to be started by a letter followed by any number of letters (or) digits.

Letter followed by any number of letters OR digits

Letter followed by any number of letters AND digits.

How they are different ??

Letter followed by any number of letters AND digits.

this means letter should be followed by both letters and digits.

A3 and AB will be rejected in this case

@karthikeyan
(L U D) or L+D defines elements either in L or in D or in both. In question they have asked "letters or digits", hence LUD.

It has to be started by a letter

Question is of form- R.E. which starts with L

Hence answer is C
Simply

Option C. L(L+D)*

1
13,474 views