Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java - LinkedList compareTo method ----------------------------------------------------- please implement the method. if the parameter list is longer and a positive integer if the current list object

Java - LinkedList compareTo method

-----------------------------------------------------

please implement the method. if the parameter list is longer and a positive integer if the current list object is longer.

----------------------------------

public linkedList{

.....

public int compareTo(LinkedList list){

//please implement this method

}

}

-----------------------------------------------------------------------

//example

current linkedlist have 6 nodes: a b c x y z

other linkedlist have 6 nodes: a b c x y z

this should return 0, since both have same amount of Nodes, and the object in the nodes are the same, and same order

ex.

other linkedlist have 3 nodes: a b c

current linkedlist is have 6 nodes: d b o x y z

If the first nonmatching value of its current list object compares as less than the corresponding value of its parameter list, the method should return some negative integer. This method should return a negative integer if the parameter list is longer and a positive integer if the current list object is longer

----

ex.

current linkedlist is: a b c x y z g d b

other linkedlist is: a b c

this should return positive number,

ex.

other linkedlist is: a b c

current linkedlist is: a b x c y z a d b c

this should return positive number

---

If the first nonmatching value of the current list

object is greater than the corresponding value of the parameter list and If all of the values of its current list object and its parameter list compare identically, except one list is longer. this method should return some positive integer

}

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

Step: 3

blur-text-image

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

Database Security XI Status And Prospects

Authors: T.Y. Lin, Shelly Qian

1st Edition

0412820900, 978-0412820908

More Books

Students also viewed these Databases questions

Question

2. Share student successes through notes or email messages.

Answered: 1 week ago