*This preview shows
pages
1–2. Sign up
to
view the full content.*

CS 521: Data Structures and Algorithms 1
Fall 2009-2010 Homework 1
1. (20 Pts) Rank the following functions by order of growth; that is, ﬁnd an arrangement
g
1
, g
2
, . . . , g
25
of the functions satisfying
g
1
= Ω(
g
2
)
, g
2
= Ω(
g
3
)
, ..., g
24
= Ω(
g
25
). Partition your list into equiva-
lence classes such that
f
(
n
) and
g
(
n
) are in the same class if and only if
f
(
n
) =
θ
(
g
(
n
)):
(3
/
2)
n
(
√
2)
log
n
log
*
n
n
2
(log
n
)!
n
3
log
2
n
log
n
!
2
2
n
n
1
/
log
n
log log
n
n.
2
n
n
log log
n
ln
n
2
n
2
log
n
(log
n
)
log
n
4
log
n
(
n
+ 1)!
√
log
n
n
!
2
√
2 log
n
n
n
log
n
n
100
2. (20 Pts) Compute the running time of the following algorithms (justify your answers). We may
assume multiplication and computing sqrt(n) takes constant time.
(a)
Algorithm veryodd(n)
for i= 1 to n
if odd(i) then
begin
for j=i to n do x<--x+1
for j=1 to i do y<--y+1
endif
endfor
end algorithm
______________________________________
(b)
Algorithm what(n)
for i= 1 to floor( sqrt(n) )
do
for j= floor( sqrt(n) ) downto 1 do

This
** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

*Sign up*
This is the end of the preview. Sign up
to
access the rest of the document.