Presentation is loading. Please wait.

Presentation is loading. Please wait.

Recursion (summary). Two Categories  Translation of recursive definition  Factorial: fact(1) = 1; fact(N) = N * fact(N-1)  Mystery: m(0) = 0; m(1)

Similar presentations


Presentation on theme: "Recursion (summary). Two Categories  Translation of recursive definition  Factorial: fact(1) = 1; fact(N) = N * fact(N-1)  Mystery: m(0) = 0; m(1)"— Presentation transcript:

1 Recursion (summary)

2 Two Categories  Translation of recursive definition  Factorial: fact(1) = 1; fact(N) = N * fact(N-1)  Mystery: m(0) = 0; m(1) = 3; m(N)=3*m(N-1)+5*m(N-2)  Divide and Conquer  Hanoi: break problem of N into 2 problems of N-1 and “combine” solutions  Guessing game: break problem of N into problem of N/2 and “combine”

3 In-Class Assignment  Work in groups of up to three students  Make sure that you turn in your paper with all group member’s names printed CLEARLY at the top  This WILL be graded (though I’m not sure how soon)

4 Questions 1.Write a C function to compute Ackermann’s function (see definition of Ackermann’s function on screen. 2.Write a C function to compute a single element of Pascal’s triangle, pascal(m,n). Use the Pascal’s triangle shown on the screen. HINT: use divide and conquer, at each step converting a problem of with row N into a problem with row N-1. 3.Solve the puzzle shown on the screen.


Download ppt "Recursion (summary). Two Categories  Translation of recursive definition  Factorial: fact(1) = 1; fact(N) = N * fact(N-1)  Mystery: m(0) = 0; m(1)"

Similar presentations


Ads by Google