Data structures Flashcards

1
Q

List/array complexity

A

Build: n
Insert, delets, find: n
Case: worst
Strengths: Fast look ups, fast appends
Weakness: Fixed inserts and deletes

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

Sorted array

A

Build: nlogn
Insert delete, find: log n
case: worst

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

Stack, queue, deque

A

Build: n
IDF: 1
case: worst
Strength: Fast operations
Uses: BFS (Queue) DFS(Stack)

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

Dynamic array

A

BUild: n
ID: 1
find: log n
case: average
Strengths: Fast lookups, variable size
Weaknesses: Slow worst-case appends. Costly insert and deletes

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

Heap/Priority queue

A

Build: n logn
idf: log n
case: worst
Strength: Heap used to implement a priority queue

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

Hash table

A

build: n
idf: 1 but in fact m
case: expected
Strengths: Fast Lookups, flexible keys
Weaknesses: Unordered

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

Skip list

A

Build: nlogn
idf: logn
case expected

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

BST

A

idf: n
case: worst
Strength: Sorted
Weakness: Poor performance if unbalanced.

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

AVL, Red-Black,B-tree

A

Build: nlogn
idf: log n
case: worst

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

Adj list

A

Build: n_m
id: deg(v)
find vertex: n
find edge(v,w): deg(v)
case: worst

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

Graph adjacency matrix

A

: Find vertex: log n
Find edge: n
Case: worst

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

k-d tree

A

Build: nlogn
idfL logn
case: worst
Range queries in k-dimensional space

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

Union-find/disjoin-set

A

Build: n log n
case: worst
Useful for tracking items that can be partitioned into disjoint sets

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

Trie

A

Build: n
idf: m

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

2d array

A

Build: nm
case: worst

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

adaptable/Location-aware heap

A

Build: nlog n

17
Q

Why would you use any tree?

A

Store information that is hierarchical in nature: Library file system
Tree traversall making searching specific data reasonable.