Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This question is about the linked list class: What are a and c? class List f cla

ID: 3678385 • Letter: T

Question

This question is about the linked list class:

What are a and c?

class List f class ListNode ( int value: ListNode nexti ListNode firsti /Return true if the value d is in the list and false " otherwise. The value d is in the list if d is equal * to the value field of any of the ListNodes in the * ist. 1 ns oun ish boolean findInList (int d) ( return findInListaux (d, stompo To e /* Return true if the value d is in the sub-list : beginning with the ListNode node. * private boolean findInListaux(int d, ListNode node) t

Explanation / Answer

a) What is the base case of the recursion in findInListAux?
=> if there is no element in the list just return false.
Condition for no element in the list is (node == null)
so base case
if (node == null){
   return false;
}


c) Write the body of the function findInListAux ?

private boolean findInListAux(int d, ListNode node){
   if (node == null){
       return false;
   }
   if (node.value == d){
       return true;
   }
   return findInListAux(d,node.next);
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote