COMPILER DESIGN

LEXICAL ANALYSIS

REGULAR EXPRESSIONS AND FINITE AUTOMATA

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Regular expression for all strings starts with ab and ends with bba is.
A
aba*b*bba
B
ab(ab)*bba
C
ab(a+b)*bba
D
All of the above
Explanation: 

Detailed explanation-1: -Regular expression for all strings starts with ab and ends with bba is. Explanation: Starts with ab then any number of a or b and ends with bba. 12. How many DFA’s exits with two states over input alphabet 0, 1 ?

Detailed explanation-2: -*’ will match all strings starting with ‘aa’. #6 The dollar($): It implies the last character of a string. ‘. *b$’ will match all strings ending with a ‘b’.

Detailed explanation-3: -Example strings = aaba, aaaba, aabba, aaabba, aababa, ………and all other strings that can start with aa and end with ba.

Detailed explanation-4: -The Regular Expression b*ab*ab*, over a, b correspond to: The set of all strings containing exactly 2a’s.

Detailed explanation-5: -A regular expression describes a set of strings. The simplest case is one that describes a particular string; for example, the string ‘ foo ‘ when regarded as a regular expression matches ‘ foo ‘ and nothing else. Nontrivial regular expressions use certain special constructs so that they can match more than one string.

There is 1 question to complete.