Doubly Linked Lists Flashcards

1
Q

There are 3 attributes of a DLL node, what are they

A

T item
DLLNode next
DLLNode prev

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

If there is only one element in the DLL what will the node look like

A

Data space is filled
Next is null
Prev is null

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

What does the first node (head) of a DLL look like

A

Data
Next points to next node in DLL
Prev is null

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

What does the last node in a DLL look like

A

Data
Next is null
Prev points to previous node in the DLL

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

What does a middle node in a DLL look like

A

Data
Next points to the next node in the DLL
Prev points to the previous node in the DLL

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

Steps to insert a node at the end of a DLL

A

Make a temp node, with data and null prev and next

Connect prev to what used to be tail

Assign tail to new temp node

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

Steps to insert a node in the middle of a DLL

A

Find position we want to add at

Make a temp node with data and null prev and next

Change next of previous node to point to temp

Change prev of temp node to point to previous node

Change prev of next node to point to temp node

Change next of temp node to point to next node

Now it is part of the list

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

benefits of doubly linked lists

A

can iterate in reverse

can be extended - do not need to know the exact amount of elements needed beforehand

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

order of growth for searching a doubly linked list

A

big O (N)

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

how should nodes be updated to prevent losing access to them

A

one side at a time

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

disadvantage of a linked list

A

must search through entire list before accessing

if searching, it’ll take iterating through the entire list before discovering that an element doesn’t exist in the list

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

benefits of a linked list

A

easy to insert anywhere into the list

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