linkedlist concatenate def __add__(self,other)if type(self!type(other)raise typeerror("concatenate undefined for str(type(self)str(type(other)) result linkedlist( cursor self first getnext( while cursor !noneresult append(cursor getitem()cursor cursor getnext( cursor other first getnext( while cursor !noneresult append(cursor getitem()cursor cursor getnext( return result concatenation is an accessor method that returns new list comprised of the two original lists the operation is once again (nfor linked lists as it was for the pylist datatype presented in fig in this concatenation code variable called cursor is used to step through the nodes of the two lists this is the common method of stepping through linked list set the cursor to the first element of the linked list then use while loop that terminates when the cursor reaches the end ( the special value noneeach time through the while loop the cursor is advanced by setting it to the next node in the sequence notice in the code that the dummy node from both lists ( self and otheris skipped when concatenating the two lists the dummy node in the new list was created when the constructor was called linkedlist append def append(self,item)node linkedlist __node(itemself last setnext(nodeself last node self numitems + the code in sect is the first time we see small advantage of linkedlist over list the append operation has complexity of ( for linkedlists where with lists the complexity was an amortized ( complexity each append will always take the same amount of time with linkedlist linkedlist is also never bigger than it has to be howeverlinkedlists take up about twice the space of randomly accessible list since there has to be room for both the reference to the item and the reference to the next node in the list this copy belongs to 'acha