I need to write a function that finds the most frequent starting letter in a text. The text is parsed by spaces and all the words are linked using a linked list which is sorted lexicographically. I wrote a function the finds the number of appearances of a starting letter and now need to write a recursive function that returns the most frequent letter.
This is the function for the number of appearances:
public int howManyStarting (char letter) {
int counter=0;
WordNode current= _head;
while (current != null){
if (current.getWord().charAt(0) == letter){
counter += current.getNumOfAppearance();
}
current = current.getNext();
}
return counter;