AlgFl03T1

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

Info iconThis 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.
Background image of page 1

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

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

This note was uploaded on 02/10/2012 for the course CSE 5211 taught by Professor Dmitra during the Spring '12 term at FIT.

Page1 / 2

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

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online