Linked Lists Flashcards

1
Q

Linked List

A

A data structure that represents a sequence of nodes. If you’d like to find the Kth element in the list, you will need to iterate through K elements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Singly Linked List

A

Each node points to the next node in the linked list.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Doubly Linked List

A

Each node points to both the next node and the previous node.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Create a Linked List w/ Node class

A

Access the linked list through a refrence to the head Node. Store data and next Node within one Node. Be careful when multiple objects need a reference to the linked list. If the head of the linked list changes, some objects might still point to the old head. A wrapper class could contain the head as a field and resolves the issue.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Deleting a Node from a Linked List

A

Given node n, find previous node prev and set prev.next equal to n.next. If doubly linked, update n.next.prev to n.prev. Always check for null pointer and update head/tail of linked list of necessary.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Runner or second pointer technique

A

Iterate through linked list with two pointers simultaneously. The fast node is either ahead by a fixed amount or jumps multiple nodes for every one jump of the slow pointer.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Recursive Problems and Linked Lists

A

If you are having trouble with a linked list problem check if recursion will work.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly