This is using the Java Linked List. I have 2 linked lists. I would like to add them together by linking the last node in the 0th list to the 0th node in the 1st list. Currently I can append them together by iterating through the second list and adding every element in it like so:
LinkedList<HashSet<Integer>> ll = someList;//Some random list
LinkedList<HashSet<Integer>> subSetLl = getSubsets(inSetSub);//Also some list
for (HashSet<Integer> set : subSetLl){
ll.add(set);
}
However, since these are Linked Lists, there should be a more efficient way to add them together, by pointing the end of one to the beginning of the next. Does such a thing exist?
EDIT FOR CLARITY: The current method runs in O(n) where n is the length of the 1st Linked List. Is there a O(1) method to accomplish this if both elements are Linked Lists?
java.util.List.addAll()