Hello!
I was given the task to finish writing the definitions of the Treeset class methods.
I'm currently at the headSet and tailSet functions and quite stumped.
Here's what they look like currently, with no logic:
@Override
public SortedSet<E> headSet(E before){
SortedSet<E> set = new SearchTreeSet<E>();
headSet(root, before, set);
return set;
}
private void headSet(Node n, E before, SortedSet<E> set){
}
@Override
public SortedSet<E> tailSet(E from){
SortedSet<E> set = new SearchTreeSet<E>();
tailSet(root, from, set);
return set;
}
private void tailSet(Node n, E from, SortedSet<E> set){
}
I am a little unsure what is going on there, why are there two declarations of the same method, but with different return types? I know that one is a 'helper' function, but I don't understand exactly what it's doing. Is the helper function what gets called initially and contains the base case? And since the private method contains the recursion, why is it void? Won't it be returning a call the function?
Also, if someone could help me out by explaining the logic of what these functions do (not writing code), that would be great as well.
Thank you!