Guest User

Untitled

a guest
Jan 21st, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. public static Poly diff (Poly p) throws NullPointerException {
  2. //EFFECTS: If p is null throws NullPointerException
  3. // else returns the Poly obtained by differentiating p.
  4. Poly q = new Poly ( );
  5. for (int i = 1; i <= p.degree( ); i++)
  6. q = q.add(new Poly(p.coeff(i)*i, i - 1));
  7. return q;
  8. }
  9.  
  10. public static IntSet getElements (int[ ] a)
  11. throws NullPointerException {
  12. //EFFECTS: If a is null throws NullPointerException else returns a set
  13. // containing an entry for each distinct element of a.
  14. IntSet s = new IntSet( );
  15. for (int i = 0; i < a.length; i++) s.insert(a[i]);
  16. return s;
  17. }
Add Comment
Please, Sign In to add comment