Question: This is a basic class structure: public class SinglyLinkedList { private Link head; private Link tail; //... private static class Link { private E data;

This is a basic class structure: public class SinglyLinkedList { private Link head; private Link tail; //... private static class Link { private E data; private Link next; //... } } I want to have a O(n) method that could appear in SinglyLinkedList that appends one list to the end of the other. public SinglyLinkedList append(SinglyLinkedList other)

The method will take the nodes of the other SinglyLinkedList and append copies of them to the end of this list. The method should not change the other list. You should return this list. Example : If a has {1,2,3} and b has {4,5,6} Then after a.append(b), it should be 1,2,3,4,5,6

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!