a Newbie needing help with recursion

hi everyone. I need some help. Im pretty new to programming and i need some advice on how to do something. My program is about recursion, taking a string(word) and permuting it in all the possible ways like in "jumble" in newspapers. Can someone show me the way to use PrintWriter function to store permutation everytime? Can someone start me off like this:

public void perm(String s, PrintWriter fileOut)

for example, the word cat will have the permutations:
cat, cta, act, atc, tca, tac and I need to store this in a file, preferrably in Microsot Word so that the wrong words will be underlined in red, thus leaving me with the answer to the jumbled word. I greatly appreciate the help. P.S. This is my first post on this forum. I am glad I found somewhere I can go to for some help.

Comments

  • [b][red]This message was edited by dysphunktional at 2004-4-3 1:14:10[/red][/b][hr]
    [b][red]This message was edited by dysphunktional at 2004-4-3 1:7:52[/red][/b][hr]
    as far as the algorithm for this goes, i would just take a word and run it through
    a double for loop, in the first run of the loop, you store a unique character in the word which hasnt been compared yet, then in the second run
    you iterate over all the possible combinations of the characters in the word follwing this unique character, rinse, and repeat until all the characters in the word have been tried. yoiu can store each string from every run of the loop into a string aray, as far as writing it to a file or whatever you're on your own as this is not the most difficult hting in the world to figure out.
    hope you understand my explanation and this helps you!
    peace

    : hi everyone. I need some help. Im pretty new to programming and i need some advice on how to do something. My program is about recursion, taking a string(word) and permuting it in all the possible ways like in "jumble" in newspapers. Can someone show me the way to use PrintWriter function to store permutation everytime? Can someone start me off like this:
    :
    : public void perm(String s, PrintWriter fileOut)
    :
    : for example, the word cat will have the permutations:
    : cat, cta, act, atc, tca, tac and I need to store this in a file, preferrably in Microsot Word so that the wrong words will be underlined in red, thus leaving me with the answer to the jumbled word. I greatly appreciate the help. P.S. This is my first post on this forum. I am glad I found somewhere I can go to for some help.
    :





Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion