Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Need help with understanding recursion.

  1. #1
    Member
    Join Date
    Dec 2012
    Location
    Detroit Mi
    Posts
    122
    My Mood
    Amazed
    Thanks
    14
    Thanked 0 Times in 0 Posts

    Default Need help with understanding recursion.

    Hello Everyone,

    I just wanted to know if anyone can help me understand a recursion problem. I'm trying to create a recursion method. My professor wants to me find the number of times a specific character, or set of characters appears in the name of a word. I actually understand the topic but I don't know where to begin with this problem. Can anyone help me?


  2. #2
    Member
    Join Date
    Nov 2013
    Location
    Bangalore, India
    Posts
    70
    My Mood
    Cool
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Default Re: Need help with understanding recursion.

    Please write code based on your algorithm. If you face any problems with code do post here to get advice.

  3. #3
    Member
    Join Date
    Dec 2012
    Location
    Detroit Mi
    Posts
    122
    My Mood
    Amazed
    Thanks
    14
    Thanked 0 Times in 0 Posts

    Default Re: Need help with understanding recursion.

    Hello dineshj83,

    Thank you for the quick response. To be honest with you I don't know how to approach this problem. I understand the overall concept but writing the code has been a bit of challenge for me. I will tell you want I know.

    I know that I need to find how many times specific character or set of character appear in my word.
    i.e Google
    G - 1
    o - 2
    g - 2
    l - 1
    e - 1
    go - 1
    goo - 2
    goog - 1
    ...
    ...
    ...
    etc etc

    I know a recursion method would work in the case.


    public static String angaram(String anagram){

    if (sometype of variable == 1)
    {
    ...
    ...
    ..

    }
    else
    {
    ...
    ...
    ..
    return something * ....
    }

    }


    I know my method is pretty rough but I'm trying here. I'm asking anyone to do my work. I just would like to pointed or maybe be explained on where I might I want to start off. My professor said if you understand recursion you should't have a problem with this problem. I think I understand recursion?

  4. #4
    Member
    Join Date
    Nov 2013
    Location
    Bangalore, India
    Posts
    70
    My Mood
    Cool
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Default Re: Need help with understanding recursion.

    For identifying number of characters repeating in a given word you don't have to recurse instead you need to loop through the string for each character. I hope this algorithm helps you to write code.

  5. #5
    Member
    Join Date
    Dec 2012
    Location
    Detroit Mi
    Posts
    122
    My Mood
    Amazed
    Thanks
    14
    Thanked 0 Times in 0 Posts

    Default Re: Need help with understanding recursion.

    My professor wants us to use recursion. We can use for loops to go through my array but not evaluating the String.

Similar Threads

  1. Recursion
    By qns in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 29th, 2013, 05:04 AM
  2. Help me Understanding Please...
    By Jabetha in forum What's Wrong With My Code?
    Replies: 4
    Last Post: August 17th, 2011, 01:55 PM
  3. Recursion Help
    By WeaKeN in forum Algorithms & Recursion
    Replies: 10
    Last Post: May 27th, 2011, 08:17 AM
  4. [SOLVED] Recursion help
    By Actinistia in forum Java Theory & Questions
    Replies: 3
    Last Post: March 21st, 2011, 12:26 PM
  5. Recursion Help
    By vmr in forum Algorithms & Recursion
    Replies: 3
    Last Post: April 1st, 2010, 11:27 PM