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.]

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

PLEASE SEND ME FAST

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.
Transcribed Image 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.
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY