Help me...

Results 1 to 2 of 2

Thread: Help me...

  1. #1
    Andy Hoernecke Guest

    Default Help me...

    I am preping for a state computer fundamentals competition. On a sample test there was a problem using regular expressions. I had never heard of these before. I looked some web-site up on the internet, but none of them gave me all the information I needed.<BR>The sample problem is as follows:<BR>The word cababba can be generated by which regular expression?<BR>a. (c+a)*(ab)*ba<BR>b. (c+ab)*ba<BR>c. a(ab)*ba<BR>d. at least two of these<BR>e. none of these<BR><BR>The answer given is d. I used a java applet on a website to find that "cababba" was matched by all three of the expressions. My problem is interpreting the expression. When there is an expression such as (c+a) in parenthesis followed by an operator how does the operator affect the statement? My best guess at this point is that it sort of distributes through the enclosed statement such as:<BR>(c+a)* = (c+)*(a)* or<BR>(c+ab)* = (c+)*(ab)*<BR>Is this correct? Otherwise how does it work?<BR><BR>Thanks,<BR>Andy Hoernecke<BR>

  2. #2
    Sergio Guest

    Default RE: Help me...

    Well, it only matches A and B. About your question : it doesn&#039;t distributes.<BR>(c+a)* means : any (0 or more) repetitions of c(one or more) followed by one(only one a)<BR>This matches ca, cca, cccca and so <BR>So the truth is evaluate the first parenthesis and THEN apply the operator<BR>HTH<BR>Sergio

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts