Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static Poly diff (Poly p) throws NullPointerException {
- //EFFECTS: If p is null throws NullPointerException
- // else returns the Poly obtained by differentiating p.
- Poly q = new Poly ( );
- for (int i = 1; i <= p.degree( ); i++)
- q = q.add(new Poly(p.coeff(i)*i, i - 1));
- return q;
- }
- public static IntSet getElements (int[ ] a)
- throws NullPointerException {
- //EFFECTS: If a is null throws NullPointerException else returns a set
- // containing an entry for each distinct element of a.
- IntSet s = new IntSet( );
- for (int i = 0; i < a.length; i++) s.insert(a[i]);
- return s;
- }
Add Comment
Please, Sign In to add comment