#elements of seq A in seq B

Tomasz Rola rtomek at ceti.com.pl
Thu Aug 20 04:45:46 CEST 2009


On Wed, 19 Aug 2009, Neal Becker wrote:

> What would be a time efficient way to count the number of occurrences of 
> elements of sequence A in sequence B?  (in this particular case, these 
> sequences are strings, if that matters).

If A and B are rather lengthy, then maybe build a tree from elements of A 
and use it to count elements of B. I.e., tree nodes would be counters. 
Building trees in Python, however, I guess it is a little bit tricky. Of 
course it is possible. But maybe you would rather have this tree 
maintained in C.

Regards
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.      **
** As the answer, master did "rm -rif" on the programmer's home    **
** directory. And then the C programmer became enlightened...      **
**                                                                 **
** Tomasz Rola          mailto:tomasz_rola at bigfoot.com             **



More information about the Python-list mailing list