Hw3Fl05Alg

# Hw3Fl05Alg - up characteristic equation T(N = T(N-1 T(N-2...

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

CSE 5211/4081 Algorithm Analysis HomeWork 3 Due: 9/29/05 Points: 15/25 .1. Write the recurrence equation for time complexity of the following algorithm and solve it using Master Theorem. [5] Algorithm Useless (Global array A, index first , index last ) .(1) if first = = last .(2) return Else { .(3) for int i := first through last do .(4) for int j := last through first do .(5) global array B[j] := A[i]*A[j]; .(6) int mid1 := first+(last – first)/3; .(7) int mid2 := first+ 2*(last – first)/3; .(8) Useless(A, first, mid1); .(9) Useless(A, mid1 +1, mid2); .(10) Useless(A, mid2 +1, last); }; End if; End algorithm. [For lines 3 through 5 you may use the final asymptotic complexity function rather than showing the calculation via the summation series. Ignore the constant-time steps, e.g., line 6 and 7, in setting up the recurrence equation. If you are playing with any particular problem size, then use n=3^k for some integer k, e.g., n=27.] .2. Solve the following homogeneous recurrence equation for general solution by setting

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: up characteristic equation: T(N) = T(N-1) + T(N-2) [ Note that this is the Fibonacci number and not the complexity of calculating it.] The roots of the quadratic equation ax 2 + bx + c = 0 are (-b + sqareroot(b 2 – 4ac))/2a and (-b - sqareroot(b 2 – 4ac))/2a. [5] GRAD QUSETION 2b. Set up the characteristic equation for: T(N) = T(N-1) + T(N-2) +1 [5] UNDERGRAD QUESTION: 3. Solve the following recurrence equation for general solution by setting up its characteristic equation, and then mention the order (theta) function for that solution. T(N) = 2T(N-1) - T(N-2) [5] GRAD QUESTION 3. Solve the following recurrence equation for general solution by setting up its characteristic equation, and then mention the order (theta) function for that solution. T(N) = 2T(N-1) - T(N-2) +1 [5] .4. GRAD QUESTION: Analyze average case complexity of QuickSelect algorithm by setting up its recurrence equation and then solving it by telescopic method. [5]...
View Full Document

{[ snackBarMessage ]}

### What students are saying

• 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.

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

• 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.

Dana University of Pennsylvania ‘17, Course Hero Intern

• 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.

Jill Tulane University ‘16, Course Hero Intern