//  Data Structures with Java by John R. Hubbard
//  Copyright McGraw-Hill, 2001
//  Problem 5.6 on page 106

  private static int frequency(Collection x, Object object)
  { // returns the number of objects in the given collection
    // that are equal to the given object
    int count=0;
    for (Iterator it = x.iterator(); it.hasNext(); )
      if (object.equals(it.next())) ++count;
    return count;
  }
