baxy77bax has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to compute the number of intersecting array elements for multiple arrays (essentially elements belonging to separate parts of venn diagrams). Initially and naively I thought this should be an easy thing to do and for 2 arrays it is:
1. Make a hash table for one array with keys being its elements
2. Loop through another array and count if an element exists in the previously created hash table
3. Subtract the number of shared elements from the total number of elements of each array.
But when the number of arrays increases the number of possible intersections between respective arrays increases (for A,B,C arrays we have A/B, A/C, B/C, A/B/C). So the problem I am having is how to scale the above algorithm.
Does anyone know a solution to this problem even if a limited number of sets can only be included (I think this is an NP problem thus any algorithm that can produce a solution for more than 7 arrays would be acceptable)
Thank you


Replies are listed 'Best First'.  

Re: Set intersection problem
by hv (Prior) on May 23, 2023 at 12:45 UTC  
Re: Set intersection problem
by Corion (Patriarch) on May 23, 2023 at 08:12 UTC  
Re: Set intersection problem
by salva (Canon) on May 23, 2023 at 14:02 UTC  
Re: Set intersection problem
by kcott (Archbishop) on May 23, 2023 at 15:36 UTC  
Re: Set intersection problem
by kikuchiyo (Hermit) on May 23, 2023 at 10:03 UTC  
by kikuchiyo (Hermit) on May 24, 2023 at 16:10 UTC  
Re: Set intersection problem
by tybalt89 (Monsignor) on May 23, 2023 at 15:00 UTC  
Re: Set intersection problem
by tybalt89 (Monsignor) on May 23, 2023 at 15:30 UTC  
Re: Set intersection problem
by Fletch (Bishop) on May 23, 2023 at 11:21 UTC  
Re: Set intersection problem
by karlgoethebier (Abbot) on May 23, 2023 at 18:44 UTC  
Re: Set intersection problem
by Anonymous Monk on May 23, 2023 at 09:20 UTC 