$\require{cancel}$
Problem Solving
- This is section 1.1 of your book.
- So we have decided that
- Computer science involves problem solving.
- You really should read the first paragraph of this section
- CS is problem solving
- But so is everything else.
- So perhaps CS is using computers to solve problems
- There is no single problem solving strategy or technique.
- George Polya, wrote a book called How To Solve It which has some great suggestions.
- Polya suggests a general approach:
- Understand the problem
- What are we asked to do?
- What is the input?
- What is the output?
- What do I and don't I know.
- Devise a plan
- This is the meat and potatoes of the book.
- He mentions many different approaches.
- This focuses on math problems, but we will look at it quickly
- Carry out the plan
- This includes checking at each step for correctness
- Evaluate the solution
- Can you check to see if it is correct
- Can you show it is correct.
- We will be back to Polya later.
- Our author suggests that the problem solving in cs follows
- Design
- Implementation
- Testing
- Refinement.
- There is a long standing, (bad) method of software development called the Waterfall Method that follows these steps
- Develop the Software
- Develop a plan to solve the problem
- This is sometimes called an algorithm
- Test the algorithm
- Translate the algorithm into code
- Test the code
- Use/maintain/fix the code
-
- At EVERY point you should test your solution.
- At any point you may need to go back to a previous point.
- We will investigate all of these stages in more depth later.
- There are two basic design strategies
- Top down design:
- Or functional decomposition
- Break the big problem into smaller and smaller parts
- Until the parts become easy to manage
- Bottom up design:
- What little pieces do I need to solve a problem?
- Build these and combine them to form a solution.