• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

permutation & combination

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also have a look here and here.

Good luck with your project!
 
reply
    Bookmark Topic Watch Topic
  • New Topic