Set Represntation, please help !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
I have this problem, I need to represent set in the following form [L,R] where L is the left hand-bound of the set , and R is the right hand-bound each of L and R are a collection of sets for example L= [{1},{2},{2,3}] R=[{1,2,3},{2,3,4}] [L,R]= [{ {1},{2},{2,3} } , { {1,2,3},{2,3,4} }] how can i do this in java
-
I have this problem, I need to represent set in the following form [L,R] where L is the left hand-bound of the set , and R is the right hand-bound each of L and R are a collection of sets for example L= [{1},{2},{2,3}] R=[{1,2,3},{2,3,4}] [L,R]= [{ {1},{2},{2,3} } , { {1,2,3},{2,3,4} }] how can i do this in java
There are many ways that you could represent this depending on what you are trying to do. My initial thought is a 2 element array of sets of sets e.g. Set s1 = new Set(); s1.add(1) Set s2 = new Set(); s2.add(2) Set s23 = new Set(); s23.add(3) s23.add(2) Set left = new Set{} left.add(s1} left.add(s2} left.add(s23} /* * Prepare Right Side now */ Set[] allSets = new Set[2]() allSets[0] = left; allSets[1] = right; Do the Sets in L and R have to be unique. Also why are you modelling the sets what do you expect to do with them. If it is a bit more rigid and you want to perform operations on the sets you may want to use a class to model them e.g. public Class LeftRightSet() { private Set left; private Set> right; // Further manipulation classes } Hope this helps