lecture16 - CSCI-255 Advanced Data Structures Lecture 16...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
CSCI-255 Advanced Data Structures Lecture 16
Background image of page 1

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

View Full DocumentRight Arrow Icon
Time Complexity Analysis of Recursive Algorithms b So far we have analyzed the time efficiency of nonrecursive algorithms only b How can we apply our general analysis framework/model to recursive algorithms? s Remember that in our model, the number of primitive operations or “steps” that we count include comparisons and assignments s How to count such “steps” in a recursive algorithm? b EXAMPLE: Analyze recursive algorithm to compute n ! (DONE IN CLASS)
Background image of page 2
Recursive Procedures b Pros s Often intuitive, more elegant s Result in shorter programs s Sometimes, a recursive solution may result in a faster algorithm s Usually easier to prove correctness b Cons s More overhead due to function calls s More memory used at runtime s Sometimes, not as fast as an iterative version of the algorithm
Background image of page 3

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

View Full DocumentRight Arrow Icon
Recursive Procedures (cont’d) b Any problem that can be solved recursively can be solved iteratively b Choose recursion when s you have a recursive data structure
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/26/2009 for the course MATH AND C CSCI255 taught by Professor Dr.ikergondraluja during the Spring '09 term at St. Francis Xavier, Antigonish.

Page1 / 14

lecture16 - CSCI-255 Advanced Data Structures Lecture 16...

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

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