Tuesday, July 20, 2010

Does someone know how to write an algorithm that appends one list onto another using linked list implement?

The full question (which I couldn't fit) is asking if someone knows how to write an algorithm that appends one list to another while using the linked list implementation.





I understand how to write an algorithm using the linked list implementation, but the one thing I am a little confused about is how to write an algorithm that appends (or adds) one linked list onto another linked list.

Does someone know how to write an algorithm that appends one list onto another using linked list implement?
I won't write your code for you, but if you've got a node with a pointer to the next node in the linked list, or points to null if its at the end, then to join lists a and b, you can:





a.tailnode.next = b





I'm assuming b is the pointer to the head node of list b.


No comments:

Post a Comment