Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Circular representation of SinglyLinkedList #54

Open
kaspar030 opened this issue Mar 23, 2021 · 2 comments
Open

Circular representation of SinglyLinkedList #54

kaspar030 opened this issue Mar 23, 2021 · 2 comments

Comments

@kaspar030
Copy link

kaspar030 commented Mar 23, 2021

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.

@Amanieu
Copy link
Owner

Amanieu commented Mar 23, 2021

That's a neat idea! I'm happy to accept a PR for it.

@kaspar030
Copy link
Author

That's a neat idea! I'm happy to accept a PR for it.

Cool! I'll look into it. Don't expect results soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants