Quick Summary Data Structures Flashcards

1
Q

Array

A

Strengths:
-Fast lookups
-Fast appends

Weaknesses:
-Fixed size (unless dynamic)
-Costly inserts and deletes

Worst Case
Space: O(n)
Lookup: O(1)
Append: O(1)
Insert: O(n)
Delete: O(n)

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

Hash Table

A

Strengths:
-Fast lookups
-Flexible keys (most data types can be used)

Weaknesses:
-Slow worst-case lookup
-Unordered
-Single-directional lookups (looking up key given value is O(n))
-Not cache friendly (often use linked lists, which don’t put data next to each other in memory)

Average Case
Space: O(n)
Lookup: O(1)
Insert: O(1)
Delete: O(1)

Worst Case
Space: O(n)
Lookup: O(n)
Insert: O(n)
Delete: O(n)

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

Linked List

A

Strengths:
-Fast operations on the ends
-Flexible size

Weaknesses:
-Costly lookups

Worst Case
Space: O(n)
Prepend: O(1)
Append: O(1)
Lookup: O(n)
Insert: O(n)
Delete: O(n)

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

Queue

A

Strengths:
-Fast operations

Uses:
-Breadth-first search
-Printers
-Web servers
-Processes (CPU scheduler)

Worst Case
Space: O(n)
Enqueue: O(1)
Dequeue: O(1)
peek: O(1)

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

Stack

A

Strengths:
-Fast Operations

Uses:
-Call stack
-Depth-first search
-String parsing

Can make with linked list or array- push/pop or insert/remove head

Worst Case
Space: O()
Push: O(1)
Pop: O(1)
peek: O(1)

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

Binary Tree

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