Question: Given this definition of a generic Linked List node: public class LLNode } private T data; private LLNode next; public LLNode(T data, LLNode next)

Given this definition of a generic Linked List node: public class LLNode} private T data; private LLNode next; public LLNode(T data, LLNode next)

Given this definition of a generic Linked List node: public class LLNode } private T data; private LLNode next; public LLNode(T data, LLNode next) { this.data = data; this.next = next; } public void setNext(LLNode newNext) { next = newNext; } public LLNode getNext(){ return next; } public T getData() {return data;} public void setData(T elem) {this.data = elem;} Consider the following generic LinkedList class: public class LinkedList { private LLNode head = null; private int size = 0; public T getDataAt(int index) throws Exception { if (head == null) return null; else return getDataAtHelper(0, index, head); MIITTIMI } } else return getDataAtHelper(0, index, head); // assume more methods defined... The getDataAt method returns the data contained in the LLNode object located at a specific index in the linked list. If the list is empty the method returns null. For example, if the list contained these Integers: 10 -> 33 -> 28 -> 50 -> 20, getDataAt(3); would return the value 50. Your task is to write a recursive helper method for the getDataAt method. Note that getDataAtHelper should throw an IndexOutOfBoundsException if the index passed in is out of bounds. Note that the index of the first LLNode in the list is 0. Assume the size variable tracks the number of data items on the list. private T getDataAtHelper(int curlndex, int targetIndex, LLNode curNode) throws IndexOutOfBoundsException { } /* your code here */ NOTE: Your solution must be recursive; no credit for using loops of any kind.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!