Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a method called CompareAndChangelist to be included in an application class called ListApplication that accepts two parameters list1 and list2 of type SinglelinkedList of

image text in transcribed

Write a method called CompareAndChangelist to be included in an application class called ListApplication that accepts two parameters list1 and list2 of type SinglelinkedList of integer values, and a third parameter Item of type int. If list1 and list2 are of different sizes, the method returns false, otherwise, the method replaces any element in list2 with a value equal to the last element in list1, if the summation of the element in list 1 and the corresponding element in list2 is equal to item. Assume list1 and list2 are not empty. If at least one replacement happened, the method returns true, otherwise, it returns false. Note: Write this method by calling methods of the class Singlelinkedlist. Method head: public static boolean CompareAndChangelist (SinglelinkedList list1, SinglelinkedList list2, int item) Example: Before Method call: item = 35 list1:23 26 30 2017 list2: 10 9 25 15 4 After Method call: list1:23 26 30 2017 list2: 10 17 25 17 4 In this case, the method will return true Note: as you can see the summation of 26 (in list 1) and its corresponding element in list2) 9. is 35, which is equal to item, so we eplace the element in list 2 (9) by the value of the last node in list1 which is 17. The same thing is between the elements 20 (in list 1) and 15 (in list 2). 15 is going to be replaced by 17 The rest will not change. Use the editor to format your answer Write a method called CompareAndChangelist to be included in an application class called ListApplication that accepts two parameters list1 and list2 of type SinglelinkedList of integer values, and a third parameter Item of type int. If list1 and list2 are of different sizes, the method returns false, otherwise, the method replaces any element in list2 with a value equal to the last element in list1, if the summation of the element in list 1 and the corresponding element in list2 is equal to item. Assume list1 and list2 are not empty. If at least one replacement happened, the method returns true, otherwise, it returns false. Note: Write this method by calling methods of the class Singlelinkedlist. Method head: public static boolean CompareAndChangelist (SinglelinkedList list1, SinglelinkedList list2, int item) Example: Before Method call: item = 35 list1:23 26 30 2017 list2: 10 9 25 15 4 After Method call: list1:23 26 30 2017 list2: 10 17 25 17 4 In this case, the method will return true Note: as you can see the summation of 26 (in list 1) and its corresponding element in list2) 9. is 35, which is equal to item, so we eplace the element in list 2 (9) by the value of the last node in list1 which is 17. The same thing is between the elements 20 (in list 1) and 15 (in list 2). 15 is going to be replaced by 17 The rest will not change. Use the editor to format your

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Constraint Databases

Authors: Peter Revesz

1st Edition

1441931554, 978-1441931559

More Books

Students also viewed these Databases questions

Question

Understand how to view variable importance in predicting turnover

Answered: 1 week ago

Question

2. How will the team select a leader?

Answered: 1 week ago