Summary of In-Class Presentation for April 7, 1999 Remember, the April summaries provide the information that will be needed for the final test. Today, we discussed problem solving. One should always start by answering the following questions: 1. What are the expected inputs? Are they organized in any ways? Are they supposed to be in any data ranges? Are there any size restrictions? 2. What are the expected outputs? Are they formatted in particular ways? 3. What are the tasks that must be performed? IF you have trouble answering this question, you can always consider how is each output to be produced? Which inputs must assist in determining that output? 4. What sorts of errors might arise? Remember, never trust your input? Try to do easy checks on it whenever you can. To assist in answering these questions you can use: 1. do a simple example ( limit the data sizes as much as you can). walk through what happens with a simple situation. 2. simplify temporarily. Consider each possible user separately. How would they use the problem solution. Ignore error situations for now ( but do not completely forget about them!). Remember to write down your answers to each of these questions. Once you have the answers to these four questions ( which you should always be able to figure out), you should use the main mammalian problem solving technique: divide and conquer. There are three very commonly used ways to do divide and conquer: 1. by sequence ( time): what has to happen first, what has to happen second, what next, and so on; 2. by function: what has to be done 3. by data: what are the major organizations of data? What do we need to do with each such collection? We went through several examples of divide and conquer. You should remember the two important characteristics which we have learned about solving computer-based problems in the last forty years: 1. iterate: pick a piece and do just that. Pick another piece and do that. Continue until the problem is solved. Ask specific questions or look at specific reference material when you get stuck. 2. expect to backtrack: you will make mistakes. You will have to redo or undo stuff you've done. This is expected and inevitable. To summarize, there are two things you can do to start solving any problem: 1. Understand the problem by answering the four questions early in this summary; 2. use divide and conquer, possibly more than once ( you can use it again on the individual pieces you divided the problem into with an earlier divide and conquer). Remember, you do not have to understand each piece completely. Work first with the pieces you best understand.