CS6515 EXAM 2 TEST PREP COURSEWORK SCRIPT STUDY SHEET 2026 GRADED A+, Exams of Design and Analysis of Algorithms

CS6515 EXAM 2 TEST PREP COURSEWORK SCRIPT STUDY SHEET 2026 GRADED A+

Typology: Exams

2025/2026

Available from 12/13/2025

HighMark_Prep
HighMark_Prep ๐Ÿ‡บ๐Ÿ‡ธ

5

(3)

27K documents

1 / 12

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS6515 EXAM 2 TEST PREP COURSEWORK
SCRIPT STUDY SHEET 2026 GRADED A+.
โ— Euler's Theorem. Answer: - for any N,z where gcd(z, N) = 1; that is
they are relatively prime:
- then z^(phi(n)) = 1 mod N
phi(N) = # of integers between 1 & N which are relatively prime to N
phi(N) - is called Euler's totient function
Note: Euler's Theorem is a generalization of Fermat's little theorem
for arbitrary N
โ— RSA Protocol. Answer: 1. Bob picks 2 n-bit random primes p & q
2. Bob chooses e relatively prime to (p-1)(q-1)
3. Bob publishes his public key (p*q, e)
4. Bob computes his private key: d ::: e^-1 mod (p-1)(q-1)
1. Alice looks up Bob's public key (pq, e)
2. Alice computes y:::m^e MOD N
1. Bob receives y
2. Bob decrypted: computes y^d MOD N ::: m
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download CS6515 EXAM 2 TEST PREP COURSEWORK SCRIPT STUDY SHEET 2026 GRADED A+ and more Exams Design and Analysis of Algorithms in PDF only on Docsity!

CS6515 EXAM 2 TEST PREP COURSEWORK

SCRIPT STUDY SHEET 2026 GRADED A+.

โ— Euler's Theorem. Answer: - for any N,z where gcd(z, N) = 1; that is they are relatively prime:

  • then z^(phi(n)) = 1 mod N phi(N) = # of integers between 1 & N which are relatively prime to N phi(N) - is called Euler's totient function Note: Euler's Theorem is a generalization of Fermat's little theorem for arbitrary N โ— RSA Protocol. Answer: 1. Bob picks 2 n-bit random primes p & q
  1. Bob chooses e relatively prime to (p-1)(q-1)
  2. Bob publishes his public key (p*q, e)
  3. Bob computes his private key: d ::: e^-1 mod (p-1)(q-1)
  4. Alice looks up Bob's public key (pq, e)
  5. Alice computes y:::m^e MOD N
  6. Bob receives y
  7. Bob decrypted: computes y^d MOD N ::: m

โ— RSA Pitfalls. Answer: 1. If gcd(m, N) > 1, crypto system is broken

  1. m is not too large (m < N)
  2. m is not too small, MOD N doesn't do anything
  • send m and r, padding message by m + r
  1. send same m, e times
  • can decrypt message using Chinese remainder theorem โ— Fermat's Test. Answer: - Find z where z ^(r-1) != 1 mod r --> r is composite
  • This is called a Fermat Witness --> every composite has a Fermat Witness โ— Trivial Fermat Witness. Answer: Passes Fermat's test and z where gcd (z, r) > 1. Trivial since don't really need to run Fermat's Test. โ— Non-trivial Fermat Witness. Answer: - z where gcd(z, r) = 1 that also passes Fermat's Test (z^(r-1) ::: 1 mod r)
  • if this is the case, then a composite number has many Fermat Witnesses; thus they are easy to find โ— Charmichael Numbers. Answer: - Pseudoprimes
  • Composite # with No nontrivial Fermat Witnesses
  • Inefficient to use Fermat's Test to prove a number is a composite number
  • if they all have e = 3, but different N's, the same message m can be decrypted using CRT โ— Fast Modular Exponentiation Algorithm. Answer: Inputs: x, y >= 0, N >= 1 Outputs: x^y MOD N Runtime: O(N^3)* Description: recursively squaring modulus โ— Euclid's GCD Algorithm. Answer: Inputs: x>= y >= 0 Outputs: GCD of x and y Runtime: O(n^3) Description: Recursively computes gcd(x, y) as gcd(x mod y, y). Can be used to check if two numbers are relatively prime to each other. โ— Extended Euclid's Algorithm. Answer: Inputs: x>= y >= 0 Outputs:
  1. d: gcd of x and y
  2. a, b: coefficients s.t. ax + by = d Runtime: O(N^3) Description: Will output GCD of x and y, and if this GCD is 1, it will also output the respective inverses of x and y.

โ— Explore Algorithm. Answer: Input: Graph G, and vertex v Output:

  1. visited[u] is set to true for all nodes u reachable from v Runtime: O(m) โ— Post Order Properties: Tree Edges. Answer: For edge z - > w, post(z) > post(w) โ— Post Order Properties: Back Edge. Answer: For edge z - > w, post(z) < post(w) โ— Post Order Properties: Forward Edge. Answer: For edge z - > w, post(z) > post(w) โ— Post Order Properties: Cross Edge. Answer: - For edge z - > w, post(z) > post(w)
  • Note cross edges have no ancestor-descendent relationship โ— Properties of a Graph: Cycles. Answer: A graph G has a cycle iff its DFS tree (starting from any vertex) has a back edge

โ— Finding Sink Vertex. Answer: - In DAG it's vertex with Lowest Post Order #

  • In General directed graph, this isn't true
  • However it still holds that the vertex with the largest post order # is a source SCC
  • Thus reverse graph G and look for a Source SCC with largest post order # โ— BFS Algorithm. Answer: Input: Directed or Undirected Graph G, and start vertex s Output:
  1. dist[u] - distance from s to u if s can reach u, inf otherwise
  2. prev[z] - the parent index of vertex z Runtime: O(m+n)
  • Use this for unweighted Single Source Shortest Path
  • Dist is given as the number of edges from s to u, not the sum of weights โ— DFS Algorithm. Answer: Input: Graph G Output:
  1. prev[z] - parent index of vertex z
  1. pre[z] - pre number of vertex z
  2. post[z] - post number of vertex z
  3. ccnum[z] - connected component number of z Runtime: O(m+n) โ— Dijkstra's Algorithm. Answer: Input: Graph (directed/un-directed), Start vertex. Output:
  4. dist[u] - distance from s to u if s can reach u
  5. prev[z] - parent index of vertex z Runtime: O( (n + m) * log(n) ) More sophisticated BFS that utilizes miniheap data structure. Such requires an additional log(n) time over BFS because of this โ— SCC Algorithm. Answer: Input: Directed Graph Output:
  6. Metagraph of G.
  7. Connected Component Numbers for each vertex (this comes from DFS, explained above)

Input: Graph with integer edge weights. (Note: Does not work with Infinity) Output: max flow f* โ— Edmonds-Karp Algorithm. Answer: Runtime: O(nm^2) Input: Graph with integer edge weights. (Note: Works with Infinity!) Output: max flow f* โ— Orlin Max Flow Algorithm. Answer: - Current best solution to max flow problem

  • Run Time: O(mn) โ— Augmenting Path. Answer: A path that exists on the residual graph from s - > t. This type of path implies there exists more flow that can be pushed through the graph. This occurs when there exists a path through which the minimum residual capacity F among all edges in the path is greater than 0. โ— When is a flow a max flow. Answer: When there is no augmenting path in the residual graph โ— Size(flow) =. Answer: F_out(L) - f_in(L)

โ— How to construct a min cut. Answer: - construct a max flow

  • set L to be those vertices reachable from s in the residual graph
  • This st cut then has a capacity equal to the max flow
  • maxflow = mincut โ— Ford-Fulkerson vs Edmonds-Karp. Answer: FF:
  • Finds augmenting paths using DFS or BFS
  • O(mC) time, where C is the size of the max flow
  • assumes integer capacities
  • capacities cannot be infinity EK:
  • Finds augmenting paths using BFS (is an example of FF)
  • O(nm^2)
  • No assumptions on integer capacities
  • Only requires positive capacities โ— Edmonds-Karp Number of rounds is at most. Answer: - mn
  • Every round residual graph changes by > 1 edge
  • Lemma: all edges are deleted/inserted later < n/2 times
  • Since m edges, total rounds < nm/