{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

AlgFl03T1 - CSE 4081/5211 Algorithms Fall 2003 Mid-Term Pts...

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

View Full Document Right Arrow Icon
CSE 4081/5211 Algorithms Fall 2003 Mid-Term Pts 50/60 Time 70 min Print your name, and Grad/Undergrad status 1a. Prove that x 3 = O(3 x ). [4] x 1 2 3 4 5 x 3 1 8 27 64 125 3 x 3 9 27 81 243 For all x>=1, x 3 <= c3 x , for c=1 1b. Prove that x 2 = Θ (2 x 2 – x) [6] lim (x->inf) [(2 x 2 – x )/ x 2 ] = lim (x->inf) [2 – 1/x] = 2 2. Solve the following recurrence equation [10] T n+1 = 2T n - T n-1 Characteristic equation: x 2 –2x +1=0, Solutions, x=1, 1 T(n+1) = c.(1) n + d.n.(1)^ n , for two constants c and d T(n) = c + d(n-1) = Theta(n) 3a. The following algorithm takes any sorted array of integers (both the non-decreasing and non-increasing arrays) as its input. What does the algorithm do, or what is its output? Algorithm Unknown( int [ ] a) [8] { int I=1, j=a.length; // the array is from 1 through a.length while (I<j) { if (a[I] < a[j]) { int temp=a[I]; a[I]=a[j]; a[j]=temp;}; I++; j--; }; } For non-decreasing sorted input, it reverses the input, making it non-increasing. For non-increasing sorted input, the algorithm just scans it but does not do anything.
Image of page 1

Info icon This 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