Skip to content

Conversation

@scottzec
Copy link

Linked List Comprehension Questions

Question Response
1. What advantages does a LinkedList have over an Array? Easier to add or delete elements at beginning or end of list. Better to insert an element in the middle of a LL using .next instead of iterating through entire array. Useful if not sure of array space limitations, because expensive to transfer an array's data to a bigger data structure--LL is more fluid bc its memory is not allocated in advance like an array's.
2. When is an Array more advantageous? You can easily jump to an element anywhere in the array, incl. the middle, with O(1) time.
3. What questions do you have about linked lists? I still don't understand the code for deleting a node from a doubly-linked list. What do "current.previous.next" and "current.next.previous" mean in practice? I would have thought the code looks different. For instance, for setting the previous node's to point to current's next node, why is the code "current.previous.next = current.next" ? Why the .next on the end of current.previous?

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.

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

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