HW1 - CS 521 Data Structures and Algorithms 1 Fall...

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

View Full Document Right Arrow Icon
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, find 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 for= 1 to j do O(1)-time sequence of statements endfor endfor endfor endalgorithm ______________________________________ (c) Algorithm complex(n) for i= 1 to n do j=1 while (j < n) do
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern