next up previous
Next: About this document Up: No Title Previous: No Title

Data Structures and Algorithms 2, Fall 1998
Problem Set 1 (9-11 Nov.)

  1. Arrange the following functions in an increasing sequence according to their order of growth (big-O) classes:

    displaymath184

    (The notation `` tex2html_wrap_inline190 '' denotes here and in the problems below base-2 logarithms.)

  2. Show that

    displaymath185

    (Hint: Construct an upper bound for the value of the sum using the tex2html_wrap_inline190 term, and a lower bound using the term tex2html_wrap_inline194 .)

  3. Analyze the worst-case complexity of the following ``selection sort'' algorithm:
     
               		 selectsort( tex2html_wrap_inline196 ):
    

    ( tex2html_wrap250 ) for tex2html_wrap_inline198 to n-1 do

    ( tex2html_wrap251 ) { tex2html_wrap_inline202 ; tex2html_wrap_inline204 ;

    ( tex2html_wrap252 ) for tex2html_wrap_inline206 to n do

    ( tex2html_wrap253 ) if A[j] < amin then

    ( tex2html_wrap254 ) { tex2html_wrap_inline212 ; tex2html_wrap_inline214 }

    ( tex2html_wrap255 ) tex2html_wrap_inline216 ; tex2html_wrap_inline218 }

    }

  4. Solve, by unwinding, the following recurrence equation:

    displaymath186

  5. Determine the order of growth (big-O) classes for the following recurrence equations. In each case the boundary condition is T(1) = 1, and the functions need to be considered only for values of n that are powers of 2. (Note: Item (d) is slightly more difficult than the others.)
    (a)
    T(n) = T(n/2) + 1,
    (b)
    T(n) = 2T(n/2) + n,
    (c)
    tex2html_wrap_inline228 .
    (d)
    tex2html_wrap_inline230 ,

  6. Analyze the worst-case complexity of the following recursive algorithm for determining the maximum and minimum elements of an array tex2html_wrap_inline196 , in the case when n is a power of 2.
     
              		 function  tex2html_wrap_inline236 ;
    

    begin

    ( tex2html_wrap256 ) if n=1 then return (A[1],A[1])

    else begin

    ( tex2html_wrap257 ) tex2html_wrap_inline242 ;

    ( tex2html_wrap258 ) tex2html_wrap_inline244

    ( tex2html_wrap259 ) return tex2html_wrap_inline246

    end

    end tex2html_wrap_inline248 .



Pekka Orponen
Tue Nov 3 20:30:43 EET 1998