Redirected
in Theory of Computation recategorized
1,433 views
1 vote
1 vote

Which of the following strings would match the regular expression : $p+ [3-5] *  [xyz]$?

  1. $p443y$
  2. $p6y$
  3. $3xyz$
  4. $p35z$
  5. $p353535x$
  6. $ppp5$
  1. I, IlI and VI only
  2. IV, V and VI only
  3. II, IV and V only
  4. I, IV and V only
in Theory of Computation recategorized
1.4k views

3 Answers

2 votes
2 votes
Best answer

option 4.

p+[3-5]*[xyz] = p+(3+4+5)*(x+y+z)
Since, p has to be present as the first character of each string, 
I. p443y -> matched
Il. p6y -> not matched since 6 cannot used .
III. 3xyz  -> not matched Strings must start with p.
IV. p35z  -> matched
V. p353535x  -> matched
Vl. ppp5 -> not matched Strings must end with x, or y, or z.

selected by

1 comment

p+[3-5]*[xyz] = p+(3+4+5)*(x+y+z)  how?

0
0
1 vote
1 vote
Ans (D) is right because

p+ [3 – 5]∗ [xyz]

means all string should start with p and end by x,y or z if this condition is not satisfied then rule out that options-

I. P443y = VALID

I. P6y = NOT VALID BCOZ 6 NOT PRESENT IN THE EXPRESSION

III.3xyz =NOT VALID BCOZ  NOT START WITH 'P'

IV. P35z = VALID

V. P353535X =VALID

VI. PPP5= NOT VALID BCOZ  STRING START WITH  'P' BUT NOT END WITH X,Y,OR Z

1 comment

4 is also not present in the expression ,then how  (i) is correct.

I think 4 is missing from the expression, and the expression is incomplete.
0
0
0 votes
0 votes
i think actual regular expression will be $P(3+4+5)^{*}(x+y+z)$

 So Option D will be true I, IV and V only
Answer:

Related questions