CSCI 587 Test1 February 18, 1997

  1. Design a Huffman code for the following symbols with the given frequencies.
    Symbol frequency
    a .3
    b .24
    c .2
    d .16
    e .1

    First combine d and e yielding a cumulative Frequency of .26
    Next combine b and c yielding a cumulative Frequency of .44
    Next combine a and (d e) yielding a cumulative Frequency of .56
    Next combine (a d e) and (b c) yielding a cumulative Frequency of 1.00
    This yields the tree in list notation
    (1.00 (.56 (.3=a) (.26 (.16=d)(.1=e)))
          (.44 (.24=b) (.2=c))
    )
    
    And then using the convention of 0 to the left 1 to the right
    
    Symbol Huffman-code
    a       00
    b       10
    c       11
    d       010
    e       011
    There are other solutions based on the convention for labeling left and right
    but all of them will have the lengths of the ones above.
    
  2. In the formulation of rules for Eliza explain how the rank is used. Give Eliza rules to handle both of the responses below:
    My brother gave me a birthday present.
    Oh was there a birthday party.
    My brother gave me a headache.
    Tell me more about your family.

    The rank is used to choose from the set of matching rules
    when more than one ELIZA rule matches.
    
    
    WordRank PatternOutputs
    birthday 9 ?X Oh, was there a party?
    brother 2 ?X Tell me more about your family
    I should have had you give a rule that required some pattern matching in the pattern and output. Maybe on the exam.
  3. Given the grammar below
       S    -> NP VP
       NP   -> art ADJL noun | art noun
       ADJL -> adj ADJL | adj
       VP   -> verb NP | verb
       
    1. Give a parse tree for ``The big blue marble is the earth.''

      (S (NP (art) (ADJL (adj) (ADJL (adj)) (noun))) 
         (VP (verb) (NP (art) (noun)))
      )
      

    2. Give an example of a noun phrase that is not handled by the grammar above.

      Just a noun as in "john" or "girls
      Compound noun phrases as in "girls and boys"
      

    3. Show how to extend the grammar to handle this example.

      NP -> noun for the simple noun
      NP -> NP and noun    // This is not a good solution. why?
      

  4. Given the prolog database:
    father(sam, bill)
    father(ben, bill)
    father(bill, joe)
    father(mary, joe)
    mother(ralph, mary)
    parent(X,P) :- father(X,P).
    parent(X,P) :- mother(X,P).
    sibling(X,Y) :- parent(X,P), parent(Y,P).
    
    1. What would the response be to the goal ?- father(X,bill).?

      X = sam;
      X = ben
      

    2. Give a cousin rule in prolog, where for the purpose of this question cousins are individuals that have parents that are siblings.

      cousin(X,C) :- parent(X,PX), parent(C,PC), sibling(PX,PC).
      

    1. What is a concordance?

      an alphabetical list of words in a document with a list of locations 
      where the words occur
      

    2. Describe briefly the data structures and algorithms used to construct a concordance.

      This requires some efficient search structure such as a search tree
      or a hash table for the words. Each node needs to have a linked list 
      of locations.
      The locations need to be kept up with so that the current page and current line
      need to be maintained.
      Algorithm:
         Read the words one at a time.
         Search the structure and insert the word if not already there.
         Add the location to the entry for this word.
      

    3. What is meant by authorship analysis?

      Using statistical techniques to try to attribute a document to an author.
      

    4. Explain one approach used in authorship analysis.

      Analyzing word usage frequency patterns and compare with other works 
      by this author and other potential authors. 
      Structure separation patterns is another aspect.
      

    1. Encode USC using ROT5

      ZXH

    2. Describe an approach to deciphering a substitution cipher message.

      Match up the most frequent characters in the cipher text with the
      frequencies for English. i.e., map the most frequent character to SPACE,
      the next to `T', and the next to `A' etc.
      

  5. Consider the sentence ``the blue waters are cold.''
    1. What lexical ambiguity occurs in this sentence?

      waters can be both a noun and a verb
      
      

    2. Show the trace of the top down parse of this sentence. Do only 6 steps where a step is a match of a lexical item or the application of a rule.

    Step Current Alternatives
    ((S) 1) ()
    1 ((NP VP) 1) ()
    2 ((art ADJL noun VP) 1) ((art noun VP) 1)
    3 ((ADJL noun VP) 2) (((art noun VP) 1))
    4 ((adj ADJL noun VP) 2) (((adj noun VP) 2)((art noun VP) 1))
    5 ((ADJL noun VP) 3) (((adj noun VP) 2)((art noun VP) 1))
    6 ((adj ADJL noun VP) 3) (((adj noun VP) 3)((adj noun VP) 2)((art noun VP) 1))
    for test stop here
    Fails to match adj Backup to previous state
    7 ((adj noun VP) 3) (((adj noun VP) 2)((art noun VP) 1))
    Fails to match adj Backup to previous state
    8 ((adj noun VP) 2) (((art noun VP) 1))
    9 (( noun VP) 3) (((art noun VP) 1))
    10 (( VP) 4) (((art noun VP) 1))

  6. In RSA encryption given the choices p = 7 and q = 11:
    1. What is n?

      n = 7 * 11 = 77
      

    2. What is phi(n)?

      phi(n) = (7-1)*(11-1) = 60
      

    3. Given e = 13, exteuclidean(77, 13) = 37 and exteuclidean(60, 13) = 6 (you need only one of these values), What is the public key?

      (77,13)
      

    4. What is the private key?

      d = 6
      

    5. Explain how the encoding would work.

      Calculate c = me mod n = m13 mod 77

    6. Explain how the decoding would work.

      Calculate decoded = cd mod n = c6 mod 77

  7. Extra Credit Describe the operation of the Enigma machine