Hi Dear all,
I'd like to use Lisp language to implemet following operations on Set.
- Set Union
- Set Difference
- Set Interaction
Detailed requirement like this:
Set Union, Set Difference, And Set Intersection.
Implement these three operations on
sets. You should be able to handle two sets as input at a minimum,
ideally any number of sets. If you need to look up these set
operations in a discrete math book, then do that. The input
representation and output representation is up to you. However, the
results should not contain duplicates (e.g., if set X = (1 2 3) and
set Y = (2 3 4) then X + Y (X UNION Y) = (1 2 3 4) NOT (1 2 2 3 3 4)
and so on).
Example: (and this is ONLY NOTIONAL - An IDEA not a specification)
INPUT FILE
----------
SET A = {a b c d e}
SET B = {x y z a}
* <--- meaning INTERSECTION
---------
Your program should perform set intersection and print out 'a'.
I heard it should be easy by using Lisp.
Any suggestions on that?
Thanks,
:-)
In article <·················@yahoo.com>, Steve <··········@yahoo.com> wrote:
>I'd like to use Lisp language to implemet following operations on Set.
Are you taking the same class as ········@cisco.com? Maybe the two of you
should get together and try to figure it out yourselves. :)
--
Barry Margolin, ······@genuity.net
Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
Just have my news-group correctly setup with my email address.
Sorry to bother and thanks for suggestions.
Barry Margolin wrote:
> In article <·················@yahoo.com>, Steve <··········@yahoo.com> wrote:
> >I'd like to use Lisp language to implemet following operations on Set.
>
> Are you taking the same class as ········@cisco.com? Maybe the two of you
> should get together and try to figure it out yourselves. :)
>
> --
> Barry Margolin, ······@genuity.net
> Genuity, Woburn, MA
> *** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
> Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
Steve wrote:
>I'd like to use Lisp language to implemet following operations on Set.
>- Set Union
>- Set Difference
>- Set Interaction
>
>Detailed requirement like this:
>
>Set Union, Set Difference, And Set Intersection.
>Implement these three operations on
>sets. You should be able to handle two sets as input at a minimum,
>ideally any number of sets. If you need to look up these set
>operations in a discrete math book, then do that. The input
>representation and output representation is up to you. However, the
>results should not contain duplicates (e.g., if set X = (1 2 3) and
>set Y = (2 3 4) then X + Y (X UNION Y) = (1 2 3 4) NOT (1 2 2 3 3 4)
>and so on).
For larger lists binary trees are much faster. O(logn) <=> O(n)
so you will most likely end up with a class discriminating between
simple short lists (standard functions) and trees (easy to write).
I miss a stability criterion in your assignment. This would influence
your choice. hashes can also be used.
--
Reini Urban
http://tv.mur.at/film/