Question: Assuming an IntNode class defined like this: public class IntNode { public int data; public IntNode next; public IntNode(int data, IntNode next) { this.data =

Assuming an IntNode class defined like this:

 public class IntNode { public int data; public IntNode next; public IntNode(int data, IntNode next) { this.data = data; this.next = next; } public String toString() { return data + ""; } 

Implement a method that will add a new integer before a target integer in the list. The method should return a pointer/reference to the front node of the resulting list. If the target is not found, it should return front without doing anything:

 public static IntNode addBefore(IntNode front, int target, int newItem) { /* COMPLETE THIS METHOD */ } 

Please I need two things with this ex. One that you graph the LL and two the screenshot that compiles. Thanks!

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 Databases Questions!