CMPSC 130A Midterm Prep

0.0(0)
studied byStudied by 8 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/57

flashcard set

Earn XP

Description and Tags

Prof Vigoda UCSB F25

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

58 Terms

1
New cards

Adjacency List space

O(n + m)

2
New cards

Adjacency List traversal

O(n + m)

3
New cards

Adjacency List lookup

O(n)

4
New cards

Adjacency list insertion

O(n)

5
New cards

Adjacency Matrix Space

O(n^2)

6
New cards

Adjacency Matrix Traversal

O(n^2)

7
New cards

Adjacency Matrix insertion

O(1)

8
New cards

Adjacency Matrix Lookup

O(1)

9
New cards

DFS Runtime

O(n + m)

10
New cards

Explore runtime (all of the calls to it combines)

O(m)

11
New cards

f grows no faster than g

f = O(g)

12
New cards

f grows at the same rate as g

f = Theta(g)

13
New cards

f grows at least as fast as g

f = Omega(g)

14
New cards

number of edges in undirected graph

m <= n choose 2

15
New cards

number of edges in directed graph

m <= n(n-1)

16
New cards

Algo for marking all the connected components

DFS-cc

17
New cards

DFC-cc runtime

O(n + m)

18
New cards

edges from a non-child descendant to an ancestor

back edges

19
New cards

edges from a non-parent node to a descendant

forward edges

20
New cards

edges to a non-ancestor and non-descendant

cousin edges

21
New cards

what two arrays do we add to DFS to make it work for directed graphs?

pre and post

22
New cards

Kosaraju’s Algo (SCC) runtime

O(n + m)

23
New cards

What algorithm do we use to split the graph into SCCs?

Kosaraju’s Algo

24
New cards

BFS runtime

O(n + m)

25
New cards

Dijkstra’s Runtime

O(log n(n+m))

26
New cards

Dijkstra’s insert runtime

O(log n)

27
New cards

Dijkstra’s insert inputs

heap H, node v, dist dist[v]

28
New cards

Dijkstra’s deletemin runtime

O(log n)

29
New cards

Dijkstra’s deletemin inputs

heap H

30
New cards

Dijkstra’s decreasekey runtime

O(log n)

31
New cards

Dijkstra’s decreasekey inputs

heap H, node v, dist[v]

32
New cards

Dijkstra’s inputs:

Graph G, weights w, start node s

33
New cards

Subgraph that is connected and acyclic

Tree

34
New cards

Subgraph that is acyclic

Forest

35
New cards

Number of edges in a tree

n - 1

36
New cards

Inputs to Kruskal’s Algorithm

G, w

37
New cards

Greedy algo for getting an MST

Kruskal’s Algorithm

38
New cards

Kruskal’s runtime

O(m log n)

39
New cards

Prim’s algorithm inputs

G, w

40
New cards

Prim’s algorithm runtime

O(m log n)

41
New cards

an edge that is guaranteed to be in the MST of a graph

cut

42
New cards

top sort runtime

O(n + m)

43
New cards

SP-DAG Inputs

Graph G, weights w, start node s

44
New cards

SP-DAG runtime

O(n + m)

45
New cards

Union-Find makeset() runtime

O(1)

46
New cards

Union-Find find() runtime

O(log n)

47
New cards

Union-Find union() runtime

O(log n)

48
New cards

Hashing with a linked list at each array index

Chain Hashing

49
New cards

Hashing method using two hash functions, and placing the item into the bucket with lesser load

2-choice hashing

50
New cards

Max load of a bucket in a one-function hash

log n

51
New cards

Max load of a bucket in a two-function hash

log log n

52
New cards

Hashing method using one bit array and multiple hash functions

Bloom Filter

53
New cards

Chain Hashing LL Insert() runtime

O(1)

54
New cards

Chain Hashing LL Find() runtime

O(log n)

55
New cards

Chain Hashing LL Delete() runtime

O(log n)

56
New cards

Bloom filter: fraction bits still 0 after n insertions

e^(-kn/m)

57
New cards

Bloom filter: false positive rate

(1 - e^(-kn/m))^k

58
New cards

Max load of a bucket in a d-function hash

log log n / log d