Question: BJP5 Exercise 16.21: surroundWith Language/Type: Java implementing Linked Lists LinkedlntList Related Links: LinkedlntList.java Author: Marty Stepp (on 2019/09/19) Write a method called surroundWith that takes

BJP5 Exercise 16.21: surroundWith Language/Type: Java implementing Linked Lists LinkedlntList Related Links: LinkedlntList.java Author: Marty Stepp (on 2019/09/19) Write a method called surroundWith that takes an integer x and an integer y as parameters and surrounds all nodes in the list containing the value x with new nodes containing the value y. In particular, each node that contains the value x as data should have a new node just before it and just after it that each contain the value y. If no nodes in the list contain the value x, then the list should not be modified. For example, suppose that the variables list1, list2, and list3 store the following sequences of values: and we make the following calls: list1.surroundWith (1,4);// surround 15 with 4s list2.surroundWith (1,1); // surround 1s with 1s list3.surroundWith (3,4); // surround 3s with 4s then the variables will now store these sequences: Assume that you are adding this method to the LinkedIntList class as defined below: public class LinkedintList \{ private ListNode front; // null for an empty list \}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
