You are on page 1of 2

EE434 – Computer Algorithms Assignment 1

Registration Number: 2014-EE-121

Name: Hassan Ali

Do Problems 0.1, 0.2, 0.3, and 0.4 from Exercise of Chapter 0.

Please note that you should be able to justify and explain your solution and answers when submitting
the assignment.

Problem 0.1

f(n) g(n) f = Ω(g) f = O(g) f = Θ(g))


n – 100 n - 200 Y
n1/2 n2/3 Y
100n +
log n n + (log n)2 Y
n log n 10n log 10n Y
log 2n log 3n Y
10 logn log(n2) Y
n1.01 n log2 n Y
n2 /logn n(log n)2 Y
n0.1 (log n)10 Y
(log n)log
n n/ logn Y
√n (log n)3 Y
n1/2 5log2 n Y
n2n 3n Y
2n 2n+1 Y
n! 2n Y
(log n)log
n 2(log2 n)2 Y
∑(i=1 to n) ik nk+1 Y
EE434 – Computer Algorithms Assignment 1

Problem 0.2
0.2. Show that, if c is a positive real number, then g(n) = 1 + c + c2 + · · · + cn is:
(a) Θ(1) if c < 1.
(b) Θ(n) if c = 1.
(c) Θ(cn) if c > 1.

(a) Θ(1) if c < 1.

g(n) = 1+(some number less than 1) ; which is constant hence the constant runtime.

(b) Θ(n) if c = 1.

g (n) = 1+1+…+1(n times) = n; which is clearly Θ(n).

(c) Θ(cn) if c > 1.

g (n) = 1 + c + … + cn ; the greatest term is cn hence it is upper-bound by cn.

Problem 0.4
(a) Show that two 2 × 2 matrices can be multiplied using 4 additions and 8 multiplications.

There are four terms in the answer. Each requires 1 addition and 2 multiplications.
(b) Show that O(log n) matrix multiplications suffice for computing X n. (Hint: Think about
computing X8.)

For computing X8 , we can simply do X^2^2^2 which is three multiplications only and
log(8) = 3.
(c) Let M(n) be the running time of an algorithm for multiplying n-bit numbers, and assume
that M(n) = O(n2) (the school method for multiplication, recalled in Chapter 1, achieves
this). Prove that the running time of fib3 is O(M(n) log n).

The runtime for simple multiplications is M(n) = O(n2). Since each matrix multiplication
requires 8 simple multiplications i.e. c* M(n), and the regular runtime of fib3 is O(log n), so
the total runtime becomes O(M(n) log n).

You might also like