Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

CS6515 EXAM 2 2025 QUESTIONS AND VERIFIED SOLUTIONS| ABSOLUTE SUCCESS GUARANTEED., Exams of Advanced Algorithms

CS6515 EXAM 2 2025 QUESTIONS AND VERIFIED SOLUTIONS| ABSOLUTE SUCCESS GUARANTEED.

Typology: Exams

2024/2025

Available from 03/02/2025

N-U-R-S-E
N-U-R-S-E 🇺🇸

2

(2)

3.3K documents

1 / 21

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
P a g e | 1
CS6515 EXAM 2 2025 QUESTIONS
AND VERIFIED SOLUTIONS|
ABSOLUTE SUCCESS GUARANTEED.
Basic Properties of Trees - Correct Answer-Tree's are undirected,
connected and acyclic that connect all nodes.
1. Tree on n vertices has (n-1) edges -> would have a cycle
otherwise (more than n-1 edges means cycle)
2. In tree exactly one path between every pair of vertices
(otherwise it's not connected)
- More than 1 path implies cycle
- less than 1 path implies not connected
3. Any connected G(V, E) with |E| = |V| - 1 is a tree
Kruskal's Algorithm - Correct Answer-1. Sort E by increasing
weigt
2. Go through edges in order and add an edge to our current tree
if it doesn't create a cycle
Running Time: O(m log n), m = |E|, n = |V|
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15

Partial preview of the text

Download CS6515 EXAM 2 2025 QUESTIONS AND VERIFIED SOLUTIONS| ABSOLUTE SUCCESS GUARANTEED. and more Exams Advanced Algorithms in PDF only on Docsity!

CS6515 EXAM 2 2025 QUESTIONS

AND VERIFIED SOLUTIONS|

ABSOLUTE SUCCESS GUARANTEED.

Basic Properties of Trees - Correct Answer-Tree's are undirected, connected and acyclic that connect all nodes.

  1. Tree on n vertices has (n-1) edges - > would have a cycle otherwise (more than n-1 edges means cycle)
  2. In tree exactly one path between every pair of vertices (otherwise it's not connected)
  • More than 1 path implies cycle
  • less than 1 path implies not connected
  1. Any connected G(V, E) with |E| = |V| - 1 is a tree Kruskal's Algorithm - Correct Answer-1. Sort E by increasing weigt
  2. Go through edges in order and add an edge to our current tree if it doesn't create a cycle Running Time: O(m log n), m = |E|, n = |V|

Is there ever a reason to use cycles in a flow graph? - Correct Answer-No Flow Network Constraints: Capacity Constraint - Correct Answer- For all edges, the flow must be larger than zero, but less than the capacity of that edge Goal of Flow Problem - Correct Answer-Maximize the flow out of the source (or into the sink) of maximum size while satisfying the capacity and conservation of flow constraints. Flow Network Constraints: Conservation of Flow - Correct Answer-For all vertices (other than the starting (source) and ending (sink) vertices), the flow into v must equal the flow out of v. Ford-Fulkerson Algo - Correct Answer-1. Start with f_e = 0 for all edges

  1. Build the residual network for current flow
  2. Find st-path in residual network
  • if no such path then output f
  1. Let c(p) = min(c_e - f_e); this is available capacity along some path

What is the time to check whether or not a flow is a max flow - Correct Answer-- O(n + m)

  1. Build the residual graph takes O(n + m) time
  2. Checking if there's a path from s to t using DFS, which takes linear time. Capacity of a Cut - Correct Answer-Sum of capacities (edges) going from cut L to cut R Max-flow = Min st-cut - Correct Answer-Size of Max-flow = min capacity of a st-cut Cut Property: Key Ideas - Correct Answer-1. Take a tree T, add an edge e* will create a cycle. Removing any edge of the cycle we'll get a new tree
  3. A minimum weight edge across a cut is part of a MST Runtime: Confirm a vertex exists - Correct Answer-O(1)

Runtime: Confirm edge exists - Correct Answer-O(m) Runtime: Explore entire graph - Correct Answer-O(n + m) x mod N = - Correct Answer-x = qN + r Basic Properties of MOD - Correct Answer-if x:::y MOD N & a:::b MOD N:

  1. x+a ::: y+b MOD N
  2. xa ::: yb MODN N Time to multiply or divide 2 n-bit numbers - Correct Answer- O(n^2) Modular Inverse - Correct Answer-X is the multiplicative inverse of Z MOD N if:
  • (x * z) MOD N = 1 Notation:

Fermat's Little Theorem - Correct Answer-- If p is prime then for every 1 <= z <= p - 1:

  • z ^ (p-1) ::: 1 MOD P Note: since 1 <= z <= p - 1 that the gcd(z, p) = 1; they are relatively prime Euler's Theorem - Correct 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 - Correct 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)
  1. Bob computes his private key: d ::: e^-1 mod (p-1)(q-1)
  2. Alice looks up Bob's public key (pq, e)
  3. Alice computes y:::m^e MOD N
  4. Bob receives y
  5. Bob decrypted: computes y^d MOD N ::: m RSA Pitfalls - Correct Answer-1. If gcd(m, N) > 1, crypto system is broken
  6. m is not too large (m < N)
  7. 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 - Correct 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
  1. Fast to encrypt
  2. Factoring N into p and q to determine the inverse of e mod (p- 1)(q-1) is hard RSA Worst Features - Correct Answer-1. gcd(m, N) > 1
  • then gcd(y, N) = p (or q)
  • can then factorize N and break crypto system
  • Make sure m and N are relatively prime to each other
  1. m not too large (m < N)
  • must break messages into n bit segments
  • m < 2^n
  1. m is not too small
  • m^e mod N = m^e
  • N isn't doing anything, so easy to decrypt
  • send padded message with m + r and r
  1. Same message m, e times is a problem
  • if they all have e = 3, but different N's, the same message m can be decrypted using CRT

Fast Modular Exponentiation Algorithm - Correct Answer-Inputs: x, y >= 0, N >= 1 Outputs: x^y MOD N Runtime: O(N^3)* Description: recursively squaring modulus Euclid's GCD Algorithm - Correct 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 - Correct 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)

Post Order Properties: Cross Edge - Correct Answer-- For edge z

  • w, post(z) > post(w)

  • Note cross edges have no ancestor-descendent relationship Properties of a Graph: Cycles - Correct Answer-A graph G has a cycle iff its DFS tree (starting from any vertex) has a back edge Topological Sorting a DAG - Correct Answer-- Order vertices so that all edges go lower to higher
  • Order vertices by decreasing post order #
  • Ordering only takes O(n + m) time (make an array in advance and put in corresponding position when post order for vertex is found) Source Vertex - Correct Answer-- No incoming edges = highest post order # in DAG Sink Vertex - Correct Answer-- No outgoing edges = lowest post order # in DAG

Finding Connected Components and Topologically Sorting - Correct Answer-Undirected Graph - 1 run DFS DAG - 1 run DFS General Directed Graph - 2 runs DFS Can Metagraphs of SCC contain cycles? - Correct Answer-- No, must be a DAG SCC Algorithm Idea - Correct Answer-- Find sink SCC, output it, remove it, and repeat

  • Why Sink?
  • Since it's a sink SCC, then you only visit the other nodes in that sink SCC when you run explore Finding Sink Vertex - Correct 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 #

Dijkstra's Algorithm - Correct Answer-Input: Graph (directed/un- directed), Start vertex. Output:

  1. dist[u] - distance from s to u if s can reach u
  2. 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 - Correct Answer-Input: Directed Graph Output:
  3. Metagraph of G.
  4. Connected Component Numbers for each vertex (this comes from DFS, explained above) Runtime: O(n + m)

Kruskal Algorithm - Correct Answer-Input: connected undirected graph G, edge weights w Output: minimum spanning tree defined by the edges Runtime: O(m log(m)) or O(m log(n)) Input: Connected, undirected graph. (Must have edge weights... basis of algo) How it works: Basically Sorts edges from least to greatest and starts building the tree. Prim's Algorithm - Correct Answer-Runtime: O(m log(m)) or O(m log(n)) Input: Connected, undirected graph. (Must have edge weights... basis of algo) Output: The Minimum Spanning Tree of the graph. How it works: Starts at a vertex and adds the smallest connecting edge to unvisited node. Ford Fulkerson Algorithm - Correct Answer-Runtime: O(mC)

When is a flow a max flow - Correct Answer-When there is no augmenting path in the residual graph Size(flow) = - Correct Answer-F_out(L) - f_in(L) How to construct a min cut - Correct 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 - Correct 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 - Correct 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/ BFS Levels - Correct Answer-- Minimum number of edges from s to some vertex
  • They never decrease in residual network, can only increase
  • If we delete an edge and add it back it will increase by at least 2
  • Thus, since there are n levels, the maximum number of times we can delete and add back an edge is n/ Adding/Removing an Edge to G^f implies - Correct Answer-- Add: if add y->z, then edge z->y must be on augmenting path
  • Remove y - >z, then edge y - >z must be on augmenting path