Linked List Variants Flashcards

(24 cards)

1
Q

Array (int) Memory

A

4n

(4 bytes per int)

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

Singly Linked List (SLL) (int) Memory

A

(4+8)n
4 (int) + 8 (next pointer) = 12 bytes per node

(data + next pointer)

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

Doubly Linked Lists (DLL) (int) Memory

A

(4+16)n
4 (int) + 8 (next) + 8 (prev) = 20 bytes per node

(data + next + prev pointer)

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

Linked Lists Space

A

No unused space (only nodes you need)

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

Dynamic Array Space

A

Usually half unused after resize

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

Array Space

A

Fixed size, can waste space

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

What are the running times for Singly Linked List (SLL)? (IF, RF, IB, RB)

A

Insert Front (IF): O(1)
Remove Front (RF): O(1)
Insert Back (IB): O(n)
Remove Back (RB): O(n)

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

What are the running times for SLL with Tail? (IF, RF, IB, RB)

A

Insert Front (IF): O(1)
Remove Front (RF): O(1)
Insert Back (IB): O(1)
Remove Back (RB): O(n)

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

What are the running times for Doubly Linked List (DLL)? (IF, RF, IB, RB)

A

Insert Front (IF): O(1)
Remove Front (RF): O(1)
Insert Back (IB): O(1)
Remove Back (RB): O(1)

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

What are the running times for DLL with Tail? (IF, RF, IB, RB)

A

Insert Front (IF): O(1)
Remove Front (RF): O(1)
Insert Back (IB): O(1)
Remove Back (RB): O(1)

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

What are the running times for DLL Circular?

A

Insert Front (IF): O(1)
Remove Front (RF): O(1)
Insert Back (IB): O(1)
Remove Back (RB): O(1)

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

What are the running times for SLL Circular without Tail?

A

Insert Front (IF): O(n)
Remove Front (RF): O(n)
Insert Back (IB): O(n)
Remove Back (RB): O(n)

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

What are the running times for Static Array? (IF, RF, IB, RB)

A

Insert Front (IF): O(n)
Remove Front (RF): O(n)
Insert Back (IB): O(1)
Remove Back (RB): O(1)

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

What are the running times for Dynamic Array? (IF, RF, IB, RB)

A

Insert Front (IF): O(n)
Remove Front (RF): O(n)
Insert Back (IB): O(1/n)
Remove Back (RB): O(1/n)

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

What are the pros and cons of Singly Linked List (SLL)?

A

Pros: Simple, low memory usage.
Cons: Slow back insert/remove.

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

What are the pros and cons of SLL with Tail?

A

Pros: Fast insert at back.
Cons: Still slow remove at back.

17
Q

What are the pros and cons of Doubly Linked List (DLL)?

A

Pros: Fast both ends (insert/remove).
Cons: More memory (prev pointers needed).

18
Q

What are the pros and cons of DLL with Tail?

A

Pros: Perfect for deques (push/pop both ends fast). Cons: Slightly more complexity.

19
Q

What are the pros and cons of DLL Circular?

A

Pros: Traverse endlessly, no nullptr ends. Cons: Management slightly trickier.

20
Q

What are the pros and cons of Static Array?

A

Pros: Fast random access. Cons: Fixed size, wasted space.

21
Q

What are the pros and cons of Dynamic Array?

A

Pros: Grows automatically, random access fast. Cons: May waste half memory, resizing slow sometimes.

22
Q

Which data structures are best for implementing a Stack (LIFO)?

A

Singly Linked List (SLL)
Doubly Linked List (DLL)
Static Array (push/pop at back)
Dynamic Array (push/pop at back, amortized O(1))

23
Q

Which data structures are best for implementing a Queue (FIFO)?

A

Singly Linked List with Tail
Doubly Linked List with Tail
(Dynamic Array acceptable for small queues)

24
Q

Which data structures are best for implementing a Deque (Double-Ended Queue)?

A

Doubly Linked List with Tail
Doubly Linked List Circular
(Dynamic Array possible but less ideal due to shifting elements)