CompSci 06/101, Fall 2011, Lab 12

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: _____________

Thesaurus Questions

Consider the following example:

["point run score", "point dot", "cut run tear score", "cut valley", "cute pretty"]
Returns: [ "cut point run score tear", "cut valley", "cute pretty", "dot point" ]
  1. Explain how to identify which two entries need to be combined. Which kind of collection (list, set, or dictionary) would be helpful in determining that?
    
      
      
      
      
      
      
      
      
      
      
      
      
  2. Explain how to actually combine two entries. Which kind of collection (list, set, or dictionary) would make combining the entries easier?
  3.   
      
      
      
      
      
    
      
      
      
      

  4. Explain how to loop over the entries to compare each pair for possible combination. How will you update the list of entries once you have combined two entries?
      
      
      
      
      
      
      
      
      
      

  5. Write the function combine_entries that simply finds a pair of entries to combine, combines them, and returns True if such a combination took place, False otherwise.
      
      
      
      
      
      
      
      
      
      

Now consider this example:

["ape monkey wrench", "wrench twist strain", "monkey twist frugue strain"]
Returns: [ "ape frugue monkey strain twist wrench" ]
  1. Explain how to determine when to stop combining entries.
  2.   
      
      
      
      
      
    
      
      
      
      

  3. Write an indefinite, i.e., while, loop that calls the function combine_entries, until all entry pairs have been combined.
      
      
      
      
      
      
      
      
      
      

AuntUncle Questions

Consider the following example:

parents = ["JOE MARY FRANK", "BOB JANE MARTHA", "FRANK MARTHA ROB", "BOB AMANDA TROY"]
target = "ROB"
Returns: ["TROY"]
  1. Explain how to get the names of all the children in the list parents.
      
      
      
      
      
      
      
      
      
      

  2. Given any name, the target or the name of another child, explain how to get the names of his/her parents.
      
      
      
      
      
      
      
      
      
      

  3. Write the function, get_rents, that returns a list of the names of the parents, either 0 or 2, of the given name.
      
      
      
      
      
      
      
      
      
      

  4. Write a loop that calls the function get_rents to get all the grandparents of the target name (think about what needs to be initialized before the loop is started as well). With which kind of collection (list, set, or dictionary) would it make the most sense to hold the grandparents?
      
      
      
      
      
      
      
      
      
      

  5. Write a loop that uses the function get_rents and the collection of grandparents to find all the grandparent's children --- these are the aunts and uncles of the target name.
      
      
      
      
      
      
      
      
      
      

  6. Look at the other examples on the APT page, are there any other special cases you need to consider in determining the final answer?