LinkedLists Flashcards

1
Q

What is the runtime of addFront(x) for an SLList?

A

O(1)

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

What is the runtime of removeFront() for an SLList?

A

O(1)

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

What is the runtime of addBack(x) for an SLList?

A

O(1)

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

What is the runtime of removeBack() for an SLList?

A

O(n)

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

What interfaces does an SLList implement?

A

Stack

Queue

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

What is the runtime of addFront(x) for a DLList?

A

O(1)

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

What is the runtime of removeFront() for a DLList?

A

O(1)

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

What is the runtime of addBack(x) for a DLList?

A

O(1)

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

What is the runtime of removeBack() for a DLList?

A

O(1)

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

What interfaces does a DLList implement?

A

Deque
List
Stack
Queue

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

What is the runtime of get(i) for a DLList?

A

O(1 + min{i, n-i})

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

What is the runtime of set(i,x) for a DLList?

A

O(1 + min{i, n-i})

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

What is the runtime of add(i,x) for a DLList?

A

O(1 + min{i, n-i})

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

What is the runtime of remove(i) for a DLList?

A

O(1 + min{i, n-i})

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

What is the extra space required by a DLList to store n elements?

A

O(n)

Each of the n nodes requires two pointers, which take up O(n) space.

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

What is the backing storage of a DLList?

A

A dummy node

An integer size

17
Q

What is the backing storage of a SLList?

A

A head node
A tail node
An integer size

18
Q

Pros of a DLList

A

fairly simple implementation
not amortized time
If you have a fast way to get to the i’th node then the rest of add/remove/get/set is O(1).

19
Q

Cons of a DLList

A
Uses O(n) space
Random access (get(i), set(i,x)) is not as fast as an array.