This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

permutation & combination

 
vijay Krishnan
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sidd Kulk
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also have a look here and here.

Good luck with your project!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic