Solved

A Linked List Class Uses a Node Class with a Successor

Question 25

Multiple Choice

A linked list class uses a Node class with a successor reference next to represent nodes.A private recursive method
Node add(int index,E element,Node list) takes a reference list (referring to the first in a chain of Node objects) ,adds a node containing the given element at the given index,and returns a reference to the first node of the resulting chain.Assume that index is nonnegative and is less or equal to the size of list.Under these circumstances,the add method should handle its non-base case (index is not 0) by


A) recursively returning the value add(index,element,list.next)
B) setting list.next to add(index-1,element,list.next.and returning list
C) setting list.next to add(index,element,list.next.and returning list
D) recursively returning the value add(index-1,element,list.

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents