This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes permutation & combination Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "permutation & combination" Watch "permutation & combination" New topic
Author

permutation & combination

vijay Krishnan
Greenhorn

Joined: Jul 27, 2006
Posts: 14
hello all,

i need one program that will give the output , if the input is like this,

input keyword = "dell desktop computers"
output =

"Dell"
"Desktop"
"Computers"
"Dell Desktop"
"Dell Computers"
"Desktop Dell"
"Desktop Computers"
"Computers Dell"
"Computers Desktop"
"Dell Desktop Computers"
"Dell Computers Desktop"
"Desktop Dell Computers"
"Desktop Computers Dell"
"Computers Dell Desktop"
"Computers Desktop Dell"



thanks in Advance.
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Hopefully, no-one will just give you a solution. If you have had a go and are having trouble, show what you've done and explain the problems. Then I'm sure people will help.


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Sidd Kulk
Ranch Hand

Joined: Feb 20, 2007
Posts: 152
One thing is sure, you need to use recursion. Design an algorithm something like this:

You send the last two words of the statement to a method, which alters the sequence and returns the new sequence, which can be appended to the current string. This can be recursively called.

Hope you get some hint from this.

Njoy!!!
[ April 13, 2007: Message edited by: Sidd Cool ]
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Try describing the process (algorithm) you used to get the output example above. Once you have these steps described in English, then you can start writing Java code to perform these steps.

For example: I started with 3 words. First, I listed the possibilities using a single word. (- insert how you did this -) Next, I listed the possibilities using 2 of the 3 words...


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
Also have a look here and here.

Good luck with your project!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: permutation & combination
 
Similar Threads
ServletStream
This is just the beginning
Suggestions for Buying new laptop
permutation program
New Laptop