Regular-Expressions
Question 1 |
In some programming languages, an identifier is permitted to be a letter following 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?
(L ∪ D)+ | |
L(L ∪ D)* | |
(L⋅D)* | |
L⋅(L⋅D)* |
Question 1 Explanation:
Which is to be letter followed by any number of letters (or) digits
L(L ∪ D)*
L(L ∪ D)*
Question 2 |
Which two of the following four regular expressions are equivalent? (ε is the empty string).
- (i) (00)*(ε+0)
(ii) (00)*
(iii) 0*
(iv) 0(00)*
(i) and (ii) | |
(ii) and (iii) | |
(i) and (iii) | |
(iii) and (iv) |
Question 2 Explanation:
(00)*(ε+0),0*
In these two, we have any no. of 0's as well as null.
In these two, we have any no. of 0's as well as null.
Question 3 |
Which one of the following regular expressions over {0,1} denotes the set of all strings not containing 100 as a substring?
0*(1+0)* | |
0*1010* | |
0*1*01 | |
0(10+1)* |
Question 3 Explanation:
(A) generates 100.
(B) generates 100 as substring.
(C) doesn't generate 1.
(D) answer.
(B) generates 100 as substring.
(C) doesn't generate 1.
(D) answer.
Question 4 |
If the regular set A is represented by A = (01 + 1)* and the regular set ‘B’ is represented by B = ((01)*1*)*, which of the following is true?
A ⊂ B | |
B ⊂ A | |
A and B are incomparable | |
A = B |
Question 4 Explanation:
Both A and B are equal, which generates strings over {0,1}, while 0 is followed by 1.
Question 5 |
The string 1101 does not belong to the set represented by
110*(0 + 1) | |
1 ( 0 + 1)* 101 | |
(10)* (01)* (00 + 11)* | |
Both C and D |
Question 5 Explanation:
Options A & B are generates string 1101.
C & D are not generate string 1101.
C & D are not generate string 1101.