Dale - Computer Science Illuminated 179

Dale - Computer Science Illuminated 179 - into modules?...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
152 Chapter 6 Problem Solving and Algorithm Design Figure 6.5 An example of top-down design Main module (Main program) Level 1 Level 0 Level 3 Level 2 Abstract Particular Top Bottom modules at a lower level. These modules are the basic building blocks of our algorithm. The goal of dividing our problem into subproblems, modules, or segments is to be able to solve each module fairly independently of the others. In a computing context, one module could read data values, another could sum the values, another could print the sum, while still another compares the sum to the previous week’s totals. The design tree contains successive levels of refinement (see Figure 6.5). The top, or level 0, is our functional description of the problem; the lower levels are our successive refinements. So how do we divide the problem
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: into modules? Well, lets think for a moment how humans usually approach any big problem. We spend some time thinking about the problem in an overall sort of way, then we jot down the major steps. We then examine each of the major steps, filling in the details. If we dont know how to accomplish a specific task, we go to the next one, planning to come back and take care of the one we skipped later when we have more information. What are we doing? We are dividing the problem into subproblems; we are using the divide-and-conquer strategy. This is exactly the process you should be using in designing an algo-rithm. Write down the major steps. This then becomes your main module....
View Full Document

Ask a homework question - tutors are online