Question: java language Write the implementation of method called replaceMiddleValueWith(int newValue) inside the SingleLinkedList class. The method should replace the element stored in the middle node
java language 
Write the implementation of method called replaceMiddleValueWith(int newValue) inside the SingleLinkedList class. The method should replace the element stored in the middle node with a new value that receives as a parameter. If there are an even number of nodes, then there will be two middle nodes and the method should replace the second middle node's value. Example 1: List : 10 - 20 - 30 40 50 60 Given new value: 77 After call replaceMiddleValueWith (77) List will be: 10 - 20 30 77 50 - 60 Example 2: List : List : 1 3 2 4 6 Given new value: 9 After call replaceMiddleValueWith (9) List will be: 1 3 9 46 Notes: 1. You are NOT allowed to call any SingleLinkedList methods inside the required methods 2. Don't forget to consider empty lists and any other special cases. 3. You must submit your answers without any compilation error
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
