Micheal Cowan Micheal Cowan - 6 months ago 7x
Java Question

Returning a Linked List with recursion when the function takes a single int argument?

I'm struggling with a function involving Lucas numbers. I need to write a
recursive function that takes a single integer argument n and returns a linked list that contains the first n Lucas numbers. I just need to understand how to recursively return a linked list with only an int argument.


Use a helper function. In pseudo-code:

List <- lucas(int n) {
     lucasHelper(new LinkedList(), n);

List <- lucasHelper(List list, int n) {