0% found this document useful (0 votes)
142 views2 pages

Homework 0 CSE 101

This homework assignment for CSE 101 due on January 9th contains 5 questions. Question 1 asks students to analyze the asymptotic runtime of two algorithms. Question 2 asks students to determine if certain functions are Big-O of n^c for some constant c. Question 3 involves finding 4-cycles in graphs and developing an efficient algorithm to do so. Question 4 deals with solving a recurrence relation and identifying flaws in an attempted inductive proof. Question 5 is for extra credit and asks how much time was spent on the homework.

Uploaded by

Kel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
142 views2 pages

Homework 0 CSE 101

This homework assignment for CSE 101 due on January 9th contains 5 questions. Question 1 asks students to analyze the asymptotic runtime of two algorithms. Question 2 asks students to determine if certain functions are Big-O of n^c for some constant c. Question 3 involves finding 4-cycles in graphs and developing an efficient algorithm to do so. Question 4 deals with solving a recurrence relation and identifying flaws in an attempted inductive proof. Question 5 is for extra credit and asks how much time was spent on the homework.

Uploaded by

Kel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CSE 101 Homework 0

Winter 2015
This homework is due Friday January 9th at the start of class. Remember to justify your work even if
the problem does not explicitly say so. Writing your solutions in LATEXis recommend though not required.
Question 1 (Program Runtimes, 20 points). Consider the following programs:
Alg1(n):
For i = 1 to n
j = 1
while i+j < n
j = j+1
Alg2(n):
For i = 1 to n
j = 1
while i*j < n
j = j+1
For each of these algorithms, compute the asymptotic runtime in the form ().
Question 2 (Big-O Computations, 20 points). For each of the following functions, determine whether or
not the expression in question is (nc ) for some constant c, and if so determine the value of such a c.
Remember to justify your answer.
a(n) =

n2
7

+ 21 + log(n)

b(n) = n + (n 1) + (n 2) + . . . + 1
c(n) = 3dlog2 (n)e
d(n) = blog2 (n)c!
e(n) = 2n
Question 3 (Cycle Finding, 30 points). Recall that a 4-cycle in a graph G is a collection of four vertices
v1 , v2 , v3 , v4 so that (v1 , v2 ), (v2 , v3 ), (v3 , v4 ) and (v4 , v1 ) are all edges of G.
(a) Show that if G is a graph with |E| 2|V |3/2 , that G must contain a 4-cycle. Hint: For each vertex
v V consider all the pairs (u, w) of vertices so that u and w are both adjacent to v. If the same pair
(u, w) shows up for two different vs, show that there is a 4-cycle.
(b) Find an efficient algorithm to determine whether or not a given graph G contains a 4-cycle. What is
the asymptotic runtime of this algorithm? You should attempt to do better than the trivial algorithm of
simply checking all quadruples v1 , v2 , v3 , v4 of vertices.
Question 4 (Recurrence Relations, 30 points). Consider the recurrence relation
T (1) = 1,

T (n) = 2T (bn/2c) + n.

(a) What is the exact value of T (2n )?


(b) Give a expression for T (n). Hint: compare its value to that at nearby powers of 2.
(c) Consider the following purported proof that T (n) = O(n) by induction:
If n = 1, then T (1) = 1 = O(1).
If T (m) = O(m) for m < n, then
T (n) = 2T (bn/2c) + n = O(n) + O(n) = O(n).
Thus, T (n) = O(n).
What is wrong with this proof ? Hint: consider the implied constants in the big-Os.
Question 5 (Extra credit, 1 point). Approximately how much time did you spend working on this homework?

You might also like