comp 202 EXAM

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/135

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 10:37 AM on 5/15/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

136 Terms

1
New cards

What is the correct asymptotic relationship between 2^n and n^100? and what are the steps to answering

2^n = Ω(n^100)

Ω A grows faster than or equal to B

O A grows slower than or equal to B

Θ A grows at the same rate as B

2
New cards

Using the Master Theorem, what is the solution to T(n) = 4T(n/2) + 7n^(8/5)? and how?

Θ(n^2)

  1. aT(n/b)

  2. f(n) = 7n^(8/5) = n^8/5

  3. n^[logb (​a)]

  4. compare n^[logb (​a)] with f(n) biggest wins

3
New cards

Using the Master Theorem, what is the solution to T(n) = 2T(n/2) + n?

Θ(n log n)

if f(n) and logb (a) are the same it becomes xlogn x = logb (a)

4
New cards

How many subproblems does Strassen’s matrix multiplication reduce n×n multiplication into?

7

5
New cards

What is the expected number of rolls until a fair 6-sided die shows a 6?

6

6
New cards

If a ball numbered 1–100 is chosen uniformly at random, what is the probability that 7 ≤ n ≤ 16?

1/10

7
New cards

What is the expected running time of randomized Quicksort?

O(n log n)

8
New cards

What property must a max heap satisfy?

Every parent node is greater than or equal to its children

9
New cards

time complexity merge sort

nlogn

10
New cards

Heap week 4

Time complexity of insertItem

logn

11
New cards

Heap week 4

Time complexity of remove max

logn

12
New cards

Time complexity of heap sort

nlogn

13
New cards

Time complexity of counting sort

O(n + k)

14
New cards

Time complexity of radix sort

O(d * n)

15
New cards

how does radix sort work

132 315 827 469 507 193 657 274

  1. order the numbers by smallest digit first

  2. 132 193 274 315 827 507 657 469

  3. Then the next largest digits

16
New cards

expected length in a randomised quick sort

2 log4/3 n

17
New cards

Time complexity of the knapsack problem

O(nW )

18
New cards

Time complexity of repeating squares (fibonacci)

O(log n)

19
New cards

The time complexity of the fractional knapsack problem


O(nlog(n))

20
New cards

time complexity of interval scheduling

O(n log n)

21
New cards

What is does an undirect graph look like

<p></p>
22
New cards
What is a digraph?
A directed graph — a graph where all edges are directed.
23
New cards
What does it mean for two vertices to be adjacent?

2 vertices connected by an edge

<p>2 vertices connected by an edge</p>
24
New cards
What is an incident edge?

An edge connected to a specific vertex

<p>An edge connected to a specific vertex </p>
25
New cards
Define degree, in-degree, and out-degree.
Degree deg(v) = number of edges incident to v. In-degree indeg(v) = number of incoming directed edges. Out-degree outdeg(v) = number of outgoing directed edges.
26
New cards
If G is undirected with m edges, what is the sum of all vertex degrees?

Sum of deg(v) = 2m.

27
New cards
If G is a directed graph with m edges, what do the in-degree and out-degree sums equal?
Sum of indeg(v) = Sum of outdeg(v) = m.
28
New cards
What is a simple graph?
A graph where there is at most one edge between any pair of vertices (and no self-loops).
29
New cards
Upper bound on edges in a simple undirected graph with n vertices?
m
30
New cards
Upper bound on edges in a simple directed graph with n vertices?
m
31
New cards
What is a walk in a graph?

<p></p>
32
New cards
What is a path?
A walk where every vertex visited is distinct.
A walk where every vertex visited is distinct.
33
New cards
What is a circuit?

<p></p>
34
New cards
What is a cycle?

<p></p>
35
New cards
What is a subgraph? What is a spanning subgraph?
A subgraph H of G has vertices and edges that are subsets of G's. A spanning subgraph contains all vertices of G but only some edges.
36
New cards

What is a connected graph

<p></p>
37
New cards
What is a forest? What is a tree?
A forest is a graph with no cycles. A tree is a connected forest (connected, acyclic graph).
38
New cards
What is a spanning tree?

Contains all vertices of the original graph

graph must be connected

graph must have no cycles

39
New cards

For an undirected graph with n vertices and m edges, what are the upper bounds for connected, tree, and forest?

Connected: m >= n-1. Tree: m = n-1. Forest: m
40
New cards

what does an adjacency list look like

<p></p>
41
New cards

Explain DFS

  • Visit a neighbour

  • Keep going deeper

  • Backtrack when stuck

<ul><li><p>Visit a neighbour</p></li><li><p>Keep going deeper</p></li><li><p>Backtrack when stuck</p></li></ul><p></p>
42
New cards
What is a weighted graph?
A graph where each edge e has a numerical weight w(e). Weights may represent distances, costs, etc.
43
New cards
Define the Single-Source Shortest Path (SSSP) problem.

Given a fixed source vertex v, find the minimum-weight path from v to every other vertex u in the graph.

A-B

A-C

A-D

44
New cards
What is the length/weight of a path P with edges e1 to ek?

w(P) = sum of w(ei) for i = 1 to k.

45
New cards
What is Dijkstra's algorithm and what is its key requirement?
A greedy algorithm for SSSP that performs a weighted BFS. Requirement: all edge weights must be non-negative.
46
New cards
Why can't Dijkstra's algorithm handle negative-weight edges?
Its greedy logic assumes once a vertex is settled its distance is final. Negative edges can provide shorter paths discovered later, violating this assumption.
47
New cards

What is the Bellman-Ford algorithm's time complexity?

O(|V| x |E|).

48
New cards
What is the All-Pairs Shortest Path (APSP) problem?
Find shortest-path distances between every pair of vertices in the graph, not just from a single source.
49
New cards

Time complexity APSP using Bellman-Ford

Time: O(|V|^2 x |E|) potentially O(|V|^4).

50
New cards

Time complexity Floyd-Warshall algorithm for APSP?

Solves APSP in O(n^3) using dynamic programming

51
New cards

what is a directed walk

knowt flashcard image
52
New cards

what does an adjaceny matrix look like

knowt flashcard image
53
New cards

Explain bfs

  • Visit all immediate neighbours

  • Then neighbours of those neighbours

  • Continue outward

<ul><li><p>Visit all immediate neighbours</p></li><li><p>Then neighbours of those neighbours</p></li><li><p>Continue outward</p></li></ul><p></p>
54
New cards

Time complexity of DFS and BFS

O( V + E) V = vertices, E = edges

55
New cards
Strongly connected digraph
A digraph in which every pair of distinct vertices can reach each other.
56
New cards
Directed cycle

It means you can start at a vertex, follow the arrows on the edges, and eventually return to the starting vertex without ever going against an arrow.

57
New cards
Acyclic digraph
A directed graph with no directed cycles.
58
New cards
Flow network
A directed graph where each edge has a non-negative integer capacity.
59
New cards
Capacity of an edge
The maximum amount of flow that can pass through an edge.
60
New cards
Source vertex in a flow network
The starting vertex s from which flow originates.
61
New cards
Sink vertex in a flow network
The ending vertex t where flow is collected.
62
New cards
Flow conservation
For every vertex except s and t, total inflow equals total outflow.
63
New cards
Maximum flow problem
Finding the greatest possible flow from source s to sink t in a flow network.
64
New cards
Forwards edge in a residual network
An edge with remaining unused capacity.
65
New cards
Complexity of finding an augmenting path

O(m).

66
New cards

Time complexity of Ford-Fulkerson networks

O(|f*|m).
67
New cards
Time complexity of Edmonds-Karp
O(nm^2).
68
New cards
Bipartite graph

a graph where the vertices can be split into two separate sets so that:

  • every edge goes between the two sets

  • no edge connects two vertices in the same set

69
New cards
Matching in a bipartite graph

each vertex can appear in at most one selected edge

2 vertices cannot share the same endpoint

70
New cards

Complexity of maximum bipartite matching using flow Ford-Fulkerson

O(nm) .

71
New cards
Meaning of |f*|
The value of a maximum flow.
72
New cards
Meaning of n in complexity analysis
The number of vertices in the graph.
73
New cards
Meaning of m in complexity analysis
The number of edges in the graph.
74
New cards

strassen algorithm time complexity

knowt flashcard image
75
New cards

what is the formula for Strassen matrix T(n)

knowt flashcard image
76
New cards
What is a symmetric encryption scheme?
An encryption scheme where the same secret key K is used by both sender and receiver for both encryption and decryption.
77
New cards
What is a substitution cipher?
A symmetric cipher where the secret key is a permutation π of the alphabet; each character x is replaced by y = π(x). Decryption uses the inverse: x = π⁻¹(y).
78
New cards
What is the Caesar cipher?
A substitution cipher where each character x is replaced by y = (x + k) mod n, where n is the alphabet size and k is the secret key. Julius Caesar used k = 3.
79
New cards
How can substitution ciphers be broken?

By frequency analysis

80
New cards
What is the one-time pad?
The most secure known symmetric cipher. Alice and Bob share a random bit string K as long as the message. Encryption: C = M ⊕ K. Decryption: M = C ⊕ K.
81
New cards
Why is the one-time pad secure?
The ciphertext C = M ⊕ K is computationally indistinguishable from a random bit string, provided K was chosen randomly.
82
New cards
What are the disadvantages of the one-time pad?
(1) Alice and Bob must share a very long key K. (2) The key can only be used once — reusing it breaks security.
83
New cards
What is the key distribution problem?
The challenge of securely distributing secret keys in symmetric encryption schemes.
84
New cards
What is a public-key cryptosystem?

A system with encryption function E (public) and decryption function D (private) satisfying: D(E(M)) = M

85
New cards
What is a one-way (trapdoor) function?
The encryption function E in a public-key system; knowledge of E gives no information about D. Anyone can encrypt, but only the holder of D can decrypt.
86
New cards
What is the RSA encryption scheme?

A public-key encryption method. Its security is based on the difficulty of factoring large numbers.

87
New cards

What are the RSA key generation steps? 4

Choose two large distinct primes p and q. Set n = p·q and (Euler's Totient)φ(n) = (p−1)(q−1). Choose e (a prime number) with 1 < e < φ(n) and gcd(e, φ(n)) = 1. Find d such that ed ≡ 1 (mod φ(n)). Public key: (e, n). Private key: d.

88
New cards
What is the RSA encryption formula?

C = M^e mod n, where M is the plaintext message, e and n are the public key.

89
New cards
What is the RSA decryption formula?

M = C^d mod n, where C is the ciphertext and d is the private key.

90
New cards
How are digital signatures created in RSA?

sender computes signature S = M^d mod n using his private key d. receiver verifies by checking M ≡ S^e (mod n) using Bob's public key e.

91
New cards
What makes RSA hard to break?
Breaking RSA requires computing φ(n) = (p−1)(q−1), which requires factoring n = p·q — a problem believed to be computationally infeasible for large n.
92
New cards
State Euclid's key theorem for the GCD algorithm.
If a ≥ b > 0, then gcd(a, b) = gcd(b, a mod b).
93
New cards
What is the time complexity of Euclid's algorithm?

O(log(max{a, b}))

94
New cards

time complexity of fast (repeated squaring) exponentiation?

O(log k)

95
New cards
What is the time complexity of RSA operations?

O(log n)

96
New cards
What is φ(n) (Euler's totient) in RSA?
For n = p·q (p, q distinct primes), φ(n) = (p−1)(q−1). It is used to choose the RSA keys e and d.
97
New cards
What is a decision problem?

A computational problem whose answer is either 'yes' or 'no'.

98
New cards
How can an optimization problem be converted to a decision problem?

Add a parameter k and ask whether the objective value is at most (or at least) k.

99
New cards
What is the complexity class P?

The set of all decision problems solvable in worst-case polynomial time.

100
New cards
What does 'polynomial time' mean for problem size?

complexity is O(n^k)