Other 2005 FR Questions FR other years Be Prepared Home
Part (a)
  // adds all elements of the Set items to the q
  // postcondition: the Set items is not modified;
  //                q contains its original elements followed
  //                by the elements from items
  private void appendSetToQueue(Set items, Queue q)
    Iterator it = items.iterator();

    while (it.hasNext())

Part (b)
  // returns a Set consisting of the e-mail addresses associated with
  // the parameter alias, such that all intermediate resulting aliases
  // have been expanded;
  // precondition: alias is a key in addressBook
  public Set expandAlias(String alias)
    Set result = new TreeSet();

    Queue q = new ListQueue();

    while (!q.isEmpty())
      String token = (String)q.dequeue();
      Set items = (Set)addressBook.get(token);
      if (items == null) // not an alias
        appendSetToQueue(items, q);

    return result;

Other 2005 FR Questions | Back to Contents

Copyright © 2005 by Skylight Publishing