02. Lists, Stacks, and Queues Flashcards

1
Q

What are the main ways to implement a list?

A

Array (resizable, which is a vector)

Linked List
Singly Linked List
Doubly Linked List

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

Runtimes of Linked List vs. Arrays

A

http://prntscr.com/jfybax

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

Array Resize Strategy

A

Make sure that the resize strategy for an array is to double the size of the array each time, or else the cost for inserting goes up.

O(1)* cost per insert() if the resize strategy is to double the array each time

O(n)* if resize strategy is to incrementally increase the size of the array by 2 each time.

Also remember that it takes O(n) time to update an element in a Linked List, but O(1) in an array.

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