CSE 2221 Study Guide - Final Guide: Kernel Method

178 views3 pages

Document Summary

Recursion: a remarkably important concept and programming technique in computer science is recursion, a recursive method is simply one that calls itself. There are two quite different views of recursion: we ask for your patience as we introduce them one at a time. Question considered only later: how do those recursive methods work, do(cid:374)"t (cid:449)orry; (cid:449)e (cid:449)ill (cid:272)o(cid:373)e (cid:271)a(cid:272)k to this. If you start by insisting on knowing the answer to this question, you may never be fully capable of developing elegant recursive solutions to problems! You need to reverse a string: contract specification looks like this: If we had some way to reverse a string of length 4, say, then we could reverse a string of length 5 by: removing the character on the left end, re(cid:448)ersi(cid:374)g (cid:449)hat"s left. This is a smaller instance of exactly the same problem as we need to solve: adding the character that was removed onto the right end.