4 Replies - 2711 Views - Last Post: 05 July 2011 - 04:13 AM Rate Topic: -----

#1 ritvijpathak  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 04-July 11

Anagram without recursion

Posted 04 July 2011 - 08:38 AM

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?
Is This A Good Question/Topic? 0
  • +

Replies To: Anagram without recursion

#2 maniacalsounds  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 117
  • View blog
  • Posts: 472
  • Joined: 27-June 10

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.
Was This Post Helpful? 1
  • +
  • -

#3 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10821
  • View blog
  • Posts: 40,340
  • Joined: 27-December 08

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.
Was This Post Helpful? 1
  • +
  • -

#4 ritvijpathak  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 04-July 11

Re: Anagram without recursion

Posted 05 July 2011 - 03:03 AM

View Postmaniacalsounds, 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.

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..?
Was This Post Helpful? 0
  • +
  • -

#5 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10821
  • View blog
  • Posts: 40,340
  • Joined: 27-December 08

Re: Anagram without recursion

Posted 05 July 2011 - 04:13 AM

Did you see my previous post?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1