Results 1 to 2 of 2
Thread: [HELP] bit string confusion
 03072011, 03:00 PM #1Member
 Join Date
 Mar 2011
 Posts
 1
 Rep Power
 0
[HELP] bit string confusion
Greetings..
I am tasked to convert numbers to bit strings to identify the differences of sets
my experimental Universal set is {1,2,3,4,5,6}. and my subset is {1,3,5}
if my Universal Set's strings would be "111111" my subset would be "101010"
for further explanation one means the element of the universal set is present to the sub set. zero means, that element of the universal set does not exist on the subset. This is my problem.
universal is the number of element of the universal set. in my experiment this is 6.
set1 is the number of element of the subset. in my experiment, it would be 3.
set1str array would be the storage for the bit string of my subset.
universe array is the universal set.
num1 array is the subset.
Java Code:int set1str[] = new int[universal]; for(int i=0; i<set1; i++) { for(int j=i; j<universal;j++) { if(universe[j]==num1[i]) { System.out.print("1"); set1str[i] = 1; j=universal; } else System.out.print("0"); set1str[i] = 0; } }
this code converts the bit string to 101001...
because 1(universal set) and 1(subset) in the if statement would print "1"
then end the nested loop.
on 2(universal set) and 3(subset) in the if statement would print "0"
on 3(universal set) and 3(subset) in the if statement would print "1"
on 3(universal set) and 5(subset) in the if statement would print "0"
on 4(universal set) and 5(subset) in the if statement would print "0"
on 5(universal set) and 5(subset) in the if statement would print "1"
then my code stops..
i had an answer of 101001 which is wrong
i should have 101010...
can you please help me edit my codes?
please?
if this would be on the wrong section, i am sorry.., im just new here and because i made this code on eclipse, i posted it here on the eclipse section.
please help me. :(
:(
:(Last edited by Fubarable; 03072011 at 05:42 PM.

Moderator actions:
 Code tags added. To see how to do this yourself, please click on the link in my signature below.
 Thread moved from Eclipse forum to the New to Java forum
Similar Threads

object name confusion
By mobosecomin in forum New To JavaReplies: 4Last Post: 01202011, 03:45 AM 
Confusion here @@' Help!
By pleasurelyours in forum New To JavaReplies: 7Last Post: 06092010, 03:42 PM 
Boolean confusion
By KM88 in forum New To JavaReplies: 13Last Post: 11022009, 01:44 PM 
confusion in paragraph
By JavaJunkie in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 05192009, 03:02 PM 
Tic Tac Toe confusion
By jigglywiggly in forum New To JavaReplies: 15Last Post: 04122009, 01:47 AM
Bookmarks