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

Big O for Linked List delete #10

Open
joeyquarters opened this issue May 13, 2017 · 0 comments
Open

Big O for Linked List delete #10

joeyquarters opened this issue May 13, 2017 · 0 comments

Comments

@joeyquarters
Copy link

First, thank you for creating this course, Brian. I didn't realize how much I would enjoy the study of algorithms and recursion.

Second, I have a question regarding the Big O for Linked Lists, specifically for deletes. On line 429 of the course materials, you say that "LinkedList's adds and deletes are O(1) but the gets are O(n)". However, the delete method we implemented uses the _find method (if we are not deleting the head), which contains a loop. Would this not mean that delete is also (usually) O(n)? Building on that, would this also mean that the LinkedList is really only optimized for adds?

Looking at the Big O cheatsheet, they describe a singly linked list as having O(n) for access and search, while having O(1) for insertion and deletion, so I know I must be misunderstanding something. Could you provide a little more explanation behind this? I would greatly appreciate it 😄

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

1 participant