This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes C / C++ and the fly likes Choosing Best Arrays Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Languages » C / C++
Bookmark "Choosing Best Arrays " Watch "Choosing Best Arrays " New topic
Author

Choosing Best Arrays

Ben Ghansah
Greenhorn

Joined: Sep 10, 2013
Posts: 1
Supposing you have a 3 or more overlapping arrays (arrays having elements in common), and you wish to select 2 or more of the arrays with the maximum number of elements but less overlap as compared to the rest of the overlapping arrays.

Eg. A[4],B[6],C[5]. A+B contains 10 elements but say the overlapping element is 3, meaning it has 7 unique element. Also B+C=11 elements , but supposing it has 5 overlaps, it would mean it has only 6 unique elements. A+B+C=15. Supposing the overlaps are 11 then it means the unique elements are 4. Ect. So per the example, the best array options with most unique element would be A+B
Anand Hariharan
Rancher

Joined: Aug 22, 2006
Posts: 257

Are the elements in these 'arrays' unique? In other words, at a conceptual level, are we really talking about sets, intersection, union, cardinality, ...?

Note that if you have 'n' sets, you have 2^n combinations of sets.


"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- Antoine de Saint-Exupery
Ramesh Pramuditha Rathnayake
Ranch Hand

Joined: Oct 31, 2012
Posts: 169
    
    1

Your example cannot exists. A+B+C cannot have 11 elements in common. Anyway, this is not a problem about programming. You have to remind few maths to solve this. Try to remind Sets and sometimes, combinations and permutations.


Ramesh-X
Chan Ag
Bartender

Joined: Sep 06, 2012
Posts: 1000
    
  16
Eg. A[4],B[6],C[5]. A+B contains 10 elements but say the overlapping element is 3, meaning it has 7 unique element. Also B+C=11 elements , but supposing it has 5 overlaps, it would mean it has only 6 unique elements. A+B+C=15. Supposing the overlaps are 11 then it means the unique elements are 4. Ect. So per the example, the best array options with most unique element would be A+B


If I had to solve this problem statement, I would most probably use Venn Diagrams and a couple of simple linear equations. But what is your question?

Chan.
Chan Ag
Bartender

Joined: Sep 06, 2012
Posts: 1000
    
  16
And welcome to the Ranch. :-)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Choosing Best Arrays
 
Similar Threads
Sun Cirtification
when java is 0 indexed
Expalin the answer -- Arrays
Iterator and Vector
Iterator and Vector