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

public Node find(int x) { Node current = head; if (head.getData() == x) { return

ID: 3540642 • Letter: P

Question

public Node find(int x) {

           Node current = head;

           if (head.getData() == x) {

                return current;

           } else {

                while (current != null) {

                     if (current.getData() == x) {

                           return current;

                     }// if

                     current = current.getNext();

                }// while

           }// if else

           return null;

     }// method find

please write the above method recusively or use recursion with the same task

Explanation / Answer

public Node find(int x)

{

Node current = head;

if (head.getData() == x)

{

return current;


}

else

{

if(current != null)

{

head=current.getNext();


find(x);

}


}


return null;



}