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

3 Questions in Algorithms - Assignment 1 | CMSI 282, Assignments of Data Structures and Algorithms

Material Type: Assignment; Professor: Dorin; Class: Algorithms; Subject: Computer Science; University: Loyola Marymount University; Term: Spring 2009;

Typology: Assignments

Pre 2010

Uploaded on 08/18/2009

koofers-user-bhp
koofers-user-bhp 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CMSI 282 Problem Set #1
Due January 29, 2009
1) Prove:
a) logba = 1 / ( logab )
b) logca = ( logcb ) ( logba )
c) logb(xy) = ( logbx ) + ( logby )
d) a
log b
= b
log a
e) for any integer n 0, 1
2
+ 2
2
+ ... + n
2
= n(n+1)(2n+1) / 6
2) Which of these recurrences can be classified using the Master Theorem?
a) Ta(n) = if n = 1 then 1 else 2Ta(n-1) + (n-2)
b) Tb(n) = if n = 1 then 1 else 2Tb(n/3) + (n-2)
c) Tc(n) = if n = 1 then 1 else 3Tc(n/2) + 5n
2
d) Td(n) = if n = 1 then 1 else 2Td(n-1) + 3Td (n-2)
e) Te(n) = if n = 1 then 5 else 16Te(n/3) + 5n
3
3) Classify these recurrences using big-theta notation. In each case, indicate how you
arrived at your conclusion (e.g., MASTER THEOREM, or, REPEATED
SUBSTITUTION, etc.):
a) Ta(n) = if n = 1 then 1 else Ta(n-1) + (n-1)
b) Tb(n) = if n = 1 then 1 else 2Tb(n/3) + (n-2)
c) Tc(n) = if n = 1 then 1 else 3Tc(n/2) + 5n
2
d) Td(n) = if n = 1 then 1 else 16Td(n/3) + 5n
2
e) Te(n) = if n = 1 then 1 else 16Te(n/3) + 5n
3
f) Tf(n) = if n = 1 then 1 else 16Tf(n/4) + 5n
4
g) Tg(n) = if n = 1 then 1 else 3Tg(n/2) + 5
pf2

Partial preview of the text

Download 3 Questions in Algorithms - Assignment 1 | CMSI 282 and more Assignments Data Structures and Algorithms in PDF only on Docsity!

CMSI 282 Problem Set # Due January 29, 2009

  1. Prove: a) logba = 1 / ( logab ) b) logca = ( logcb ) ( logba ) c) logb(xy) = ( logbx ) + ( logby ) d) alog b^ = blog^ a e) for any integer n ≥ 0, 1^2 + 2^2 + ... + n^2 = n(n+1)(2n+1) / 6
  2. Which of these recurrences can be classified using the Master Theorem? a) Ta(n) = if n = 1 then 1 else 2Ta(n-1) + (n-2) b) Tb(n) = if n = 1 then 1 else 2Tb(n/3) + (n-2) c) Tc(n) = if n = 1 then 1 else 3Tc(n/2) + 5n^2 d) Td(n) = if n = 1 then 1 else 2Td(n-1) + 3Td (n-2) e) Te(n) = if n = 1 then 5 else 16Te(n/3) + 5n^3
  3. Classify these recurrences using big-theta notation. In each case, indicate how you arrived at your conclusion (e.g., MASTER THEOREM, or, REPEATED SUBSTITUTION, etc.): a) Ta(n) = if n = 1 then 1 else Ta(n-1) + (n-1) b) Tb(n) = if n = 1 then 1 else 2Tb(n/3) + (n-2) c) Tc(n) = if n = 1 then 1 else 3Tc(n/2) + 5n^2 d) Td(n) = if n = 1 then 1 else 16Td(n/3) + 5n^2 e) Te(n) = if n = 1 then 1 else 16Te(n/3) + 5n^3 f) Tf(n) = if n = 1 then 1 else 16Tf(n/4) + 5n^4 g) Tg(n) = if n = 1 then 1 else 3Tg(n/2) + 5

h) Th(n) = if n = 1 then 1 else 16Th(n/2) + 5n^4 i) Ti (n) = if n = 1 then 1 else Ti(n/3) + 2 j) Tj(n) = if n = 1 then 1 else 3Tj(n/2) k) Tk(n) = if n = 1 then 1 else Tk(n/2) l) Tl(n) = if n = 1 then 10 else nTl(n/2) m) Tm(n) = if n = 1 then 10 else 16Tm(n/16) n) T(n) = if n = 1 then 1 else 2T(n-1) + 1 o) To(n) = if n = 1 then 1 else To(n-1) + n^2 (hint: see problem 1d, above) p) Tp(n) = if n = 1 then 1 else 2Tp(n/2) + n1. q) Tq(n) = if n = 1 then 10 else 16Tq(n/16) + n r) Tr(n) = if n = 1 then 10 else 16Tr(n/17) + n