# Need help with understanding recursion.

• December 1st, 2013, 11:57 PM
Rain_Maker
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?
• December 1st, 2013, 11:59 PM
dineshj83
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.
• December 2nd, 2013, 12:17 AM
Rain_Maker
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.
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?
• December 2nd, 2013, 12:23 AM
dineshj83
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.
• December 2nd, 2013, 06:05 AM
Rain_Maker
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.