4 ms·
That's very unlikely. Even for singly linked lists, implementations for general purpose use usually keep pointers to the first and last elements so that you ca
by KMag 4y ago
That's very unlikely.
Even for singly linked lists, implementations for general purpose use usually keep pointers to the first and last elements so that you can use it as an O(1) FIFO queue, as well as prepend in O(1) time.
If you only keep a pointer to the head of the linked list, then it can be practically used a LIFO queue (stack), and a few other corner cases, but not much else. (A FIFO isn't very useful if adding an item is O(1) but removing an item is O(N), or vice versa.)