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

Earth/Taylor #32

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Earth/Taylor #32

wants to merge 2 commits into from

Conversation

TaylorMililani
Copy link

Linked List Comprehension Questions

Question Response
1. What advantages does a LinkedList have over an Array? You dont need a contiguous block of memory, and its faster to add/find/remove items at the beginning and end of the list.
2. When is an Array more advantageous? In an array you can jump to the middle in O(1) time.
3. What questions do you have about linked lists? I understand the differences in arrays and lists in terms of time complexity, but what are the differences in space complexity?

Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done Taylor, you hit the learning goals here. Nice work.

Comment on lines +10 to 12
# Time complexity - O(1) - I think these first two would be O(1) because they dont need to traverse the list, while the other 4 do so I assumed O(n) for those
# Space complexity - O(1)
def add_first(data)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +17 to 19
# Time complexity - O(1)
# Space complexity - O(1)
def get_first

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +27 to 29
# Time complexity - O(n)
# Space complexity - O(n) - I had some trouble determining space complexity of linked lists methods, I ended up assuming they were probably the same as time complexity. I made this assumption based on the call stack of operations, let me know if I'm off base or misunderstanding
def length

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 However the space complexity is O(1) since you're not creating any new lists.

Comment on lines +39 to 41
# Time complexity - O(n)
# Space complexity - O(n)
def add_last(data)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 , however the space complexity is O(1)

Comment on lines +55 to 57
# Time complexity - O(n)
# Space complexity - O(n)
def get_last

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 , however the space complexity is O(1)

Comment on lines +70 to 72
# Time complexity - O(n)
# Space complexity - O(n)
def get_at_index(index)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 , however the space complexity is O(1)

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

Successfully merging this pull request may close these issues.

2 participants