Skip to content

Conversation

@beauttie
Copy link

Linked List Comprehension Questions

Question Response
1. What advantages does a LinkedList have over an Array? You can add an element to or remove an element from the head (or the tail if doubly linked) of a LinkedList in constant time and space. To do this operation for an array, you would have to shift all elements by one index, which would be in linear time.
2. When is an Array more advantageous? To retrieve an element at a specific index
3. What questions do you have about linked lists? Other than the advantage noted above, when would you use a LinkedList over an Array?

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 Beauttie, you hit the learning goals here. Nice work.

Comment on lines +10 to 12
# Time complexity - O(1)
# 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 +23 to 25
# Time complexity - O(n)
# Space complexity - O(1)
def length

Choose a reason for hiding this comment

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

👍

Comment on lines +36 to 38
# Time complexity - O(n)
# Space complexity - O(1)
def add_last(data)

Choose a reason for hiding this comment

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

👍

Comment on lines +52 to 54
# Time complexity - O(n)
# Space complexity - O(1)
def get_last

Choose a reason for hiding this comment

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

👍

Comment on lines +65 to 67
# Time complexity - O(n)
# Space complexity - O(1)
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.

👍

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