algorithm - Given an amount of sets with numbers, find a set of numbers not including any of the given -


given amount of sets numbers (0-20 e.g) , asked find maximum set of numbers 0-20 doesn't include of given sets(it can include numbers set,but not whole set) example :setting max number 8 , given sets

{1,2}  {2,3}   {7}  {3,4}  {5,6,4}, 

one maximum solution set {1, 3, 5, 6, 8}. thinking of representing graph , inducting max independent set problem, seems work if sets consisted pairs,which doesn't stand.any idea?thanks in advance.

use bit map each set, setting appropriate bit. if there less 32 members, can use uint32_t. full set inclusion can computed masking out members (i.e. union of sets) specific bit map, , using xor specific bit map. result 0's if subset, otherwise result member max independent set.


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -