I wrote a program using recursion for generating anagrams.
But now we have to write another without using recursion.
Can anyone explain me the logic used so that I can write it?
Anagram without recursion
Page 1 of 14 Replies - 1768 Views - Last Post: 05 July 2011 - 04:13 AM
Replies To: Anagram without recursion
#2
Re: Anagram without recursion
Posted 04 July 2011 - 09:23 AM
First, please don't post two topics about the exact same thing.
Second, what do you mean? Recursion is basically where you make a call to that same method within the method if necessary. Simply take out calls to the method, and find another workaround for it.
Sorry, we can't help you much without you showing code.
Second, what do you mean? Recursion is basically where you make a call to that same method within the method if necessary. Simply take out calls to the method, and find another workaround for it.
Sorry, we can't help you much without you showing code.
#3
Re: Anagram without recursion
Posted 04 July 2011 - 09:28 AM
The big deal with recursion is that it is state-driven. Since it stores states (meaning the recursive calls) on the Java call stack, it is very easy to backtrack and go to the previous state. The way I would suggest is using your own Stack to store the states and backtrack using that.
My tutorial on Trees, Stacks, and the Iterator Pattern is a good place to start.
My tutorial on Trees, Stacks, and the Iterator Pattern is a good place to start.
#4
Re: Anagram without recursion
Posted 05 July 2011 - 03:03 AM
maniacalsounds, on 04 July 2011 - 09:23 AM, said:
First, please don't post two topics about the exact same thing.
Second, what do you mean? Recursion is basically where you make a call to that same method within the method if necessary. Simply take out calls to the method, and find another workaround for it.
Sorry, we can't help you much without you showing code.
Second, what do you mean? Recursion is basically where you make a call to that same method within the method if necessary. Simply take out calls to the method, and find another workaround for it.
Sorry, we can't help you much without you showing code.
Sorry! my mistake.
I mean that i need to write a program for printing anagrams of a given string without using recursion.
I have no idea what logic i should use. Can anyone help me with the logic only not the code..?
#5
Re: Anagram without recursion
Posted 05 July 2011 - 04:13 AM
Did you see my previous post?
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote







|