I want an algorithm to do this program in java language.?
I want an algorithm to do this program in java language.? this is the last question of my assignment of 75 long programs, which i had to write in 2 days. 74 are done without anyone's help. but this is the most difficult of all (at least for a 15yr 10th grade school student).
program for printing all the possible combinations of a word.
this is what i've thought so far...
Input a string
store its length in a var 'n'.
Fix the positions of individual words in the string.(what my teacher said).
and then make combinations.
Now the problem is -------
lets say i fix the first word.
now, we can say that we need to consider a new string, which does not have the word which we have fixed.
But if i initiate a loop from 0 to length-1 for fixing the letters, then for that i will have to make several loops, which will depend on the length.
THe no. of loops in a program is fixed, it isnt variable.
so whats the solution to the problem ???
btw i m an amateur in programming, and i have a keen interest. i hav spent 5 days in this program . today is the sixth. so please dont tell me to spent my whole life thinking how to do this, cause i also have to do other homeworks and learning.
|