You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
IIUC the SinglyLinkedList provides front(), push_front() and pop_front(), as only those can be accessed in O(1), when the list keeps track of the list head.
If the list would keep track of the list tail, with the tail (or sentinel) connected circularly, wouldn't back() and push_back() be possible in O(1), (with one indirection for the front operations, e.g., front() = back().next())?
IMO that extends the space savings of a singly linked list (vs. doubly linked list) to many more use cases.
The text was updated successfully, but these errors were encountered:
IIUC the SinglyLinkedList provides
front()
,push_front()
andpop_front()
, as only those can be accessed in O(1), when the list keeps track of the list head.If the list would keep track of the list tail, with the tail (or sentinel) connected circularly, wouldn't
back()
andpush_back()
be possible in O(1), (with one indirection for the front operations, e.g.,front() = back().next()
)?IMO that extends the space savings of a singly linked list (vs. doubly linked list) to many more use cases.
The text was updated successfully, but these errors were encountered: