Solved

java programming

Posted on 2004-09-26
9
234 Views
Last Modified: 2010-05-18


This assignment will be creating all the permutations of a word using upper and lower case letters.  For a word that is n letters long the number of permutations is 2n.  For instance; given the word "are" the possible permutations include:

are
Are
ARe
ARE
ArE
aRe
aRE
arE

Please help me to write a java progarm?
0
Comment
Question by:sraveend
  • 5
  • 4
9 Comments
 
LVL 24

Accepted Solution

by:
sciuriware earned 500 total points
ID: 12155165
No, homework is forbidden.

The only thing I will say is that every character has 2 states,
you might couple these to an array of booleans and
that to a split binary number of which the bits indicate the state (0 == lowercase).
By incrementing the binary number you can decode all possible strings.

Just try.

;JOOP!
0
 

Author Comment

by:sraveend
ID: 12159242
Could u please give me an example !!!
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 12160040
You must change characters, so you must choose between a char[] (very fast) and a StringBuffer (flexible).

For 3 characters you need:                       char[] array = new char[3];
You can count from 0 to 7 to address them:
       for(int i = 0;  i < 8;  ++i)
You can address those 3 characters by an integer:
              for(j = 0;  j < 3;  ++j)
To address 'array' from 'i' :
       if((i & (1<<j)) == 0)
       {
             array[j] = Character.toLowerCase(array[j]);
       }
       else
       {
             array[j] = Character.toUpperCase(array[j]);
       }


It's your turn now.....
;JOOP!
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:sraveend
ID: 12168930
Thanks a lot,it helped me to write the program correctly!
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 12170095
Ok, you may click [Accept] now.

Feel free to learn here, not just to copy from here (that's the rules).

;JOOP!
0
 

Author Comment

by:sraveend
ID: 12172853
Am sorry i searched & i coudn't get the link Accept........
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 12176662
After every comment ....
0
 

Author Comment

by:sraveend
ID: 12180889
I could view accept when u gave me the first solution ,but now i could see only a word comment ,after every comment
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 12187280
Are you logged in as yourself?

;JOOP!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
The viewer will learn how to implement Singleton Design Pattern in Java.

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question