Having issues with this java problem. Describe an algorithm for concatenating two singly linked lists L and M, into a single list L' that contains all the nodes of L followed by all the nodes of M. But, rather than just describe such an algorithm, create a Java program and method(s) that will do so. Consider using at least three lists. Two of them L and M (although create better names – and lowercase like ‘first’ and ‘second’) you will create and populate with GameEntry objects. The third list L’ (or ‘concat’) will contain the concatenated nodes. Create a method named concatenate () that looks
like this: public static SinglyLinkedList concatenate (SinglyLinkedListfirst, SinglyLinkedListsecond); Print the first two lists before calling concatenate. Then print the concatenated list. (And, SinglyLinkedList does contain a ‘toString’ method that can be used.) Use class SinglyLinkedList of the net.datastructures package.
here is the package and documentation for SinglyLinkedList http://cs.slu.edu/~goldwasser/dsaj/docs/
It's quite simple. You take the last node of L and have it point at the first node of M.
However, depending on your use case, you might want to copy the lists first.
That interface doesn't seem to have a means to iterate through the list. It doesn't make much sense.
Join our real-time social learning platform and learn together with your friends!