CS 106B Lecture Notes - Lecture 8: Empty String, Old Texts
Document Summary
Announcements: assignment 2 due saturday; no lair due friday night, new texts for random writer. More diversity with texts if want to see more variety in input; A problem solving technique in which problems are solved by reducing them into smaller problems of the same form: structure. Break problems into subproblems of the same form. Group and assemble results: three musts. You code must have a case for all valid inputs. When you make a recursive call it should be to a simpler instance: example: expression calculation. Only three types: a number, addition of two expressions, or multiplication of two expressions. To solve: if the expression is an integer, return the integer if the expression has an operator, separate the left and right expressions then call the recursive function on both the left and right expressions. We have to assume that the recursive function is correct.