CS 106B Lecture 7: CS 106B Lecture Notes Week 3 Mon
Document Summary
Towers of hanoi: section swaps by midnight tonight, (ow to solve it? (cid:523)we will learn (cid:524) Recursion definition: a problem-solving technique in which problems are solved by reducing large problems into smaller problems with consistent form. Why recursion: great style, powerful tool, master of control flow. Find definition of word on google: understand word. But you might not understand a portion of the: how many students behind you? definition, so need to find definition of that word. You can only see the people right next to you. Ask the person behind you how many people are behind him/ her; this cycle continues until it reaches person at the back. Break the problem into subproblems of the same form. Assemble the results of the subproblems: every recursive algorithm involves at least 2 cases. Recursive case: requires recall and repetition of function. Recursive examples (cont. : writing a function of powers/ exponentiation.