I have a singly linked list with this structure: public class SinglyLinkedList {
ID: 3916086 • Letter: I
Question
I have a singly linked list with this structure:
public class SinglyLinkedList {
private Link head;
private Link tail;
private int size;
//...
private static class Link {
private E data;
private Link next;
//...
}
}
I want to write O(n) method that could appear in SinglyLinkedList that appends one list to the end of the other.
public SinglyLinkedList<E> append(SinglyLinkedList<E> 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. And should return this list.
Explanation / Answer
This code should be able to help you what you wnated. Thanks! Do comment if you need any help on this.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.