Compsci 06/101, Fall 2011, Lab 10

By entering your name/net-id below you indicate you are present for this lab to answer these questions and that you were part of the process that resulted in answers being turned in.

Name: ______________    Net id: _____________ || Name: ______________    Net id: _____________

Name: ______________    Net id: _____________ || Name: ______________    Net id: _____________

Regex Questions

In answering questions about regular expressions you should provide both the answer, and the regular expression you used to answer the question. For example.

Question: How many words end in the letter 'a'.

Answer: There are 898 such words, the regular expression is a$, the first word is ababa and the last word is zomba.

You can use more than one regular expression to answer the questions. You can do calculations, record intermediate results, and so on. Be sure to report carefully the methods you used to arrive at your answer as well as the answer itself.

  1. How many five letter words are there that end with the letter 'd'?
    
    
    
    
    
    
    
    
    
  2. The regular expression [aeiou]$ indicates there are 6988 words that end in a vowel. How many words are there that start and end with a vowel?
    
    
    
    
    
    
    
    
  3. How many words are there that start and end with the same vowel --- words like amoeba?
    
    
    
    
    
    
    
    
    
    
  4. The words obsequious and pharmacopoeia each contain four vowels in a row. How many words are there that contain four consecutive vowels?
      
    
    
    
    
    
    
    
    
    
  5. The word maintaining contains the two letter sequence "in" repeated three times --- in genomics this could be called a triple-repeat. How many words are there that contain the two letter sequence "in" repeated three times (letters can appear between the "in" repeats)?
    
    
    
    
    
    
    
    
    
    
    
  6. The regular expression ((.).\2).*\1 matches the 12 words below (and only these words). Explain why these words match, how the regular expression works. Note that the expression (.) is the second tagged expression since the first left parenthesis begins the first tagged expression -- you count tagged expressions by the order in which the left-parenthesis appears in reading left-to-right.

    amalgamate
    amalgamated
    amalgamates
    amalgamatating
    amalgamatation
    assesses
    dereference
    monotonous
    monotonously
    monotonousness
    possesses
    sensitivities
    

  7. The regular expression ((.).\2){3} matches the two words below (and only these two words). Explain why these words match, i.e., how the regular expression works.
    agamemnon
    precipitateness
    
    
    
    
    
    
    
    

Recursion Questions

  1. What is the type of items in the list points to the function sierpinski:
    
    
    
    
    
    
        

  2. What ensures that the recursive function sierpinski will eventually terminate, i.e., stop generating recursive calls? How should that value be changed when passing it to each recursive call?
    
    
    
    
    
    
        

  3. What should be the new midpoint values of the parameter points in the first recursive call? Draw the picture that appears when only this these points are calculated.
    
    
    
    
    
    
        

  4. What should be the new midpoint values of the parameter points in the first recursive call? Draw the picture that appears when only this these points are calculated.
    
    
    
    
    
    
        

  5. What should be the new midpoint values of the parameter points in the first recursive call? Draw the picture that appears when only this these points are calculated.