CSL 102: Introduction to Computer Science
Assignment 3 : Operations using List
Date: 8.2.2010
Due Date: 22.2.2010
Part A: Operations on Polynomials
A polynomial is represented using a list of reals.
Write functions to do the following operations on polynomials.
- polyadd(P,Q) produces the polynomial sum P+Q.
- scalarmult(P,s) multiplies P by scalar s.
- polydiff(P,Q) produces P-Q.
- evalpoly(P,x) evaluates the polynomial at a given value x.
Part B: Set Operations
A set is represented using a list. The members in a set can be in any
order, and there is only one occurence of the same element on the list.
Write functions to do the following operations on sets.
- member(e,S) returns TRUE if e is a member of set S.
- insert(e,S) adds e in the S if it is not already there.
- delete(e,S) deletes e from S.
- intersection(S1,S2) gives intersection of sets S1 and S2.
- union(S1,S2) gives union of sets S1 and S2.
- difference(S1,S2) gives the difference of the sets S1 and S2.
- uncommonpart(S1,S2) gives the elements which are in S1 or S2
but not in both.