Alternatives to Singly-Linked Lists
The Doubly-Linked List
With a doubly-linked list it is no longer necessary to keep two
pointers into the list for traversals during deletions.
Deleting the node that curr point to looks like :
curr -> prev -> next = curr -> next;
The doubly-linked list requires more memory than the
singly-linked list. How much more ?
Memory is cheap ... You decide.
- For a singly-linked list, there's only one pointer per node,
which is 4 bytes big.
- For a doubly-linked list, there are 2 pointers, or 8 bytes, a
difference of 4 bytes per node
- So for a list that has 10 nodes, that's 40 more bytes and a
list of 100 nodes would require 400 more bytes
Circularly Linked List
You can't run off the end of the list.
You still have to keep track of where you started so you
don't circle indefinitely.
Of course, there are also Circular singly-linked lists. I leave
the illustration to your imagination.