Class Notes (786,419)
Canada (482,179)
CMPT 120 (44)
Greg Baker (15)
Lecture

Working with Recursion

2 Pages
62 Views
Unlock Document

School
Simon Fraser University
Department
Computing Science
Course
CMPT 120
Professor
Greg Baker
Semester
Fall

Description
11232007CMPT120Working With Recursionproblems that can be solved in pieces are good candidates for recursionowe can use recursive calls to solve the piecesoand then finishStep 1 Find a smaller subproblemoIs there some way to take part of the problem solve it and get closer to the solutionoeg for n we noticed that nnn1 usuallyso calculate n1 And were almost thereoexample Spacing out a stringie Calling spacedword should return w o r dif we can spaceout all but the last character wor becomes w o r were closeie We will spaceout s1 firstStep 2Use the subproblem solution to finishoAssuming the subproblem is correctly solved how do we finishoFor factorials if we have n1 just multiply by noeg to get from spaceds1 to spaceds append a space and
More Less

Related notes for CMPT 120

Log In


OR

Don't have an account?

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


OR

By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.

Submit