Lecture07-recurrencerels

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

CS 312: Algorithm Analysis Lecture #7: Recurrence Relations a.k.a. Difference Equations Slides by: Eric Ringger, with contributions from Mike Jones, Eric Mercer, Sean Warnick This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.

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

View Full Document
Announcements § Thought! § HW #4 Due Today § Project #2 § Help Session – how’d it go? § Early: next Friday § Due: Monday 1/30 § Much more challenging than Project #1
Objectives § Analyze Recursive Algorithms, especially for Divide and Conquer, using Recurrence Relations § Also known as Difference Equations § Today: Special Type of RRs § Homogeneous § Linear § Constant Coefficients § Leading up to a proof of the Master Theorem

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

View Full Document
Recall: Analysis Framework Given a problem, § Identify your platform’s elementary operations (sometimes implicit) § Formulate your solution as an algorithm § Define the measure of the input size § Measure time efficiency by counting the number of times an elementary operation is executed § Measure space efficiency by counting the number of memory units consumed by the algorithm § The efficiency of some algorithms may differ significantly for inputs of the same size. § Distinguish among worst-case, average-case, and best-case efficiencies. Choose one. § Plot efficiency vs. input size § Establish order of growth. Use asymptotic notation. n0 c1g(n) c2g(n) f(n) Where is the difficulty for Analyzing Recursive Functions? )) ( ( ) ( n g n f Θ =
Nonrecursive Algorithms Example : Element Uniqueness Problem, check whether all elements in an array are distinct. function UniqueElements( A[0…n-1]) for i=0 to n-2 for j = i+1 to n-1 if A[i]=A[j] return false return true Define input size Define elementary operation Distinguish worst-case ∑ ∑ - = - + = = 2 0 1 1 1 ) ( n i n i j worst n C [ ] - = - = - - = + + - - = 2 0 2 0 ) 1 ( 1 ) 1 ( ) 1 ( n i n i i n i n - = - = - - = 2 0 2 0 ) 1 ( ) ( n i n i worst i n n C - = - - - - = 2 0 2 ) 1

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.

{[ 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