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.]
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...
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.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fe19513fd-581e-4c3f-bf9d-76bb2a9073e2%2Ffdff1cb9-6b89-4003-ba9b-84bc1fc7b1f7%2Fcblkf48k_processed.png&w=3840&q=75)
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
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Recommended textbooks for you
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
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…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
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)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
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…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
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)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
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](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY