Problem 1:
For all edges (u,v) in Gcfw_
For each Vertex vcfw_
If (u,v) is an edge and (v,y) is an edge:
Add u,v,y to a list of triangles
Runtime: O(n*e) we traverse all edges once (outer loop) and w
Problem 1:
modified DFS search:
public Dfs()cfw_
load adjencyList into a queue Q
list result
int index = 0;
while Q is not emptycfw_
stack S
temp = q.pop()
if temp isVisitedcfw_
point result
Homework 2
Louis Boguslav
April 3, 2016
1
Problem 1:
x1
The Expected run time of this algorithm in terms of iterations is = E(x).
pr(x < 30) = 1 pr(2/32) = .9375
E = pr(x < 30) 1 + (1 pr(30)(E + 1)
E
Homework 1
Louis Boguslav
February 3, 2016
Problem 1 The order of functions are:
log n < log3 n <
n < 7n2 + 3n = 6n2 3 < 5n2 log n < 2n < 3n
Problem 2:
1. T (n) = 4T (n/3) + 5n
a = 4, b = 3, f (n) = 5