Top Down Design
- Pseudocode
- pseudocode - a mixture of English and computer language that
can be used to describe an algorithm
- Input, output
- if (condition) then else
- Write pseudocode compare two numbers
- while (condition) do
- Write code to find the largest number in a list, first given the number of numbers
- repeat until (condition)
- Given a set of letters, see if they are a palindrome
-
- Top down design
- Also known as functional decomposition
- A process for solving problems
- Really just divide and conquer
- Start with an abstract problem
- Break it into smaller problems
- repeat until the problem becomes manageable
- In CS we sometimes refer to the smaller problems as modules
- These are usually self-contained
- They have data inputs and outputs
- They solve the subproblem
- We move from the abstract to the concrete
- To accomplish this, we can build a structure chart (p 152)
- Example: Plan a vacation
- Plan a vacation
- Select Date
- Check Schedule for work
- Check Social Schedule
- Select Destination
- Decide on desired climate
- Decide on desired activities
- Decide on price range
- Make Reservations
- Decide on price
- Decide on required options
- Check availability
- Pack
- Notice, data flows throughout this process
- A computer example: Find the area under the curve
x2+3x+2, for any starting and ending point.
- We usually work the problem out on paper first.
- Remember Problem Solving.
- Remember Look for something we know how to do
- Read, write, save, loop, if.
- Testing
- We need to somehow verify our algorithm.
- is it correct
- This is throughout the problem solving method
- For TopDown Design
- If the modules below this are correct, is this module correct?
- Often one writes preconditions - or things that must be true before the module is called
- and postconditions - or things that are true after the module has been called.
- Desk Checking is verifying the design without using a computer
- This can be done by a "walk through" or pretend to be the computer
and follow the instruction you have written