Please read the question very carefully. Before you start to code please draw and analyze the scenarios. Complete the method updateList(head, number) where a non-dummy headed singly linked list and an...


PLEASE SEND ME FAST


Please read the question very carefully. Before you start to code please draw and analyze the<br>scenarios.<br>Complete the method updateList(head, number) where a non-dummy headed singly linked list<br>and an integer value can be taken as parameters. You have to write a python/JAVA program that<br>will find out the result of mod operation between the given integer and number of nodes of the<br>linked list and then if the result is an even number then remove the node from that index otherwise<br>insert a new node on that index containing the given integer as value. Note that you are not allowed<br>to use/create a separate linked list. You cannot use any additional methods other than countNode()<br>and nodeAt(). Return head at the end. The Node class is given below. [Note: If a valid index is<br>found from the result of mod operation for the given linked list, only then insertion/removal can<br>be done on that particular index.]<br>Sample Input<br>Sample Output<br>Explanation<br>22 6 9 18 21; 59 | 22 6 9 18<br>Here, the number of nodes of the linked list is 5 and the given<br>integer is 59. The result of 59 % 5 is 4 which is an even number<br>and represents a valid index for insertion/removal. Therefore, the<br>node at index 4 has been removed.<br>1 21 12 18 9; 38<br>1 21 12 38 189<br>Here, the number of nodes of the linked list is 5 and the given<br>integer is 38. The result of 38 % 5 is 3 which is an odd number and<br>represents a valid index for insertion/removal. Therefore, a new<br>node containing 38 as value has been inserted at index 3.<br>

Extracted text: Please read the question very carefully. Before you start to code please draw and analyze the scenarios. Complete the method updateList(head, number) where a non-dummy headed singly linked list and an integer value can be taken as parameters. You have to write a python/JAVA program that will find out the result of mod operation between the given integer and number of nodes of the linked list and then if the result is an even number then remove the node from that index otherwise insert a new node on that index containing the given integer as value. Note that you are not allowed to use/create a separate linked list. You cannot use any additional methods other than countNode() and nodeAt(). Return head at the end. The Node class is given below. [Note: If a valid index is found from the result of mod operation for the given linked list, only then insertion/removal can be done on that particular index.] Sample Input Sample Output Explanation 22 6 9 18 21; 59 | 22 6 9 18 Here, the number of nodes of the linked list is 5 and the given integer is 59. The result of 59 % 5 is 4 which is an even number and represents a valid index for insertion/removal. Therefore, the node at index 4 has been removed. 1 21 12 18 9; 38 1 21 12 38 189 Here, the number of nodes of the linked list is 5 and the given integer is 38. The result of 38 % 5 is 3 which is an odd number and represents a valid index for insertion/removal. Therefore, a new node containing 38 as value has been inserted at index 3.
Jun 02, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here