[Tutor] Lists...

Daniel Yoo dyoo@hkn.eecs.berkeley.edu
Thu, 31 May 2001 01:42:09 -0700 (PDT)


On Thu, 31 May 2001, Andrew Wilkins wrote:

> > If the lists get large, this will have horrible performance because
> > the "item in l2" performs a linear search.  If you can create a
> > dictionary from one of the lists then the speed of the inersection
> > will be improved, but time will be spent building the citionary.  (It
> > is faster because the has_key method hashes the key and checks if it
> > exists rather than performing a linear search on a list)
> 
> Ahh just what I was hoping not to receive =)
> The thing is, the lists I'm using are terribly big. What I'm doing is
> creating ranges of coordinates,
> so the lists generally will vary from 100 to 1000 elements. I'll try the
> dictionary method! If that's slow, do you think a C implementation would be
> worth the trouble? I've never tried implementing modules in C, could be fun

If it's possible to sort both lists of numbers, then taking the
intersection of two sorted lists isn't too bad either; what kind of things
will your lists contain?