600.106 Pre-programming (Algorithmic Thinking)
Intersession 2007
Basic Strategy for Algorithmic Problem Solving
Jorge Vasconcelos
This document presents some guidelines to approach the solution of a great variety of problems, particularly those presented in computer programming.
The strategy consists of five big steps:
- Read and comprehend the problem statement.
- Select theoretical concepts that may be applied.
- Qualitative description of the problem.
- Formalization of a solution strategy.
- Test and description of the solution.
Each step has attached a questionnaire, which contain questions that will lead you toward the solution of the problem or, if needed, to step back and review your work.
This document is based on the paper: Cabral, Luis G. et al. "Solucion de
Problemas". Contactos Vol II, No. 8. Oct-Dic 1985. pp.42-51. UAM-I,
ciencias basicas e ingenieria, Mexico.
Guiding-questionnaires to be used with the General Strategy for algorithm creation
Guide 1
- Do you understand every word used within the problem statement?
- What computational elements are relevant to the problem?
- What non-computational elements are relevant to the problem: Mathematics, Physics, Geography, etc.
- Use your own words to describe the problem. If needed, make a drawing depicting the situation stating clearly relevant objects and times.
- Have you solved any similar problem? If so, take advantage of that experience and its information.
- What data or resources are provided within the statement?
- What data or results are requested within the statement?
- Check answers 6 and 7 and decide if they are consistent with your answers 2 and 3.
Guide 2
- Identify all theoretical (and empirical) concepts related with the problem.
- Select a structure able to simplify data handling: arrays, records, files, local variables, global variables, linked lists, etc.
- Identify the kind of problem(s) according with its (their) structure: sequential, selection, iterative.
- Identify available algorithmic elements and select: what you need: well-defined instructions, already known algorithms, etc.
- Is it possible to simplify the problem by dividing it into simpler cases and selecting a different approach for each one? Is it possible eliminate redundant or unnecessary data?
Guide 3
- Do you know any hand-written way to solve the problem? If so, propose several examples and solve them "by hand", then attempt to create a generalization. In order to do that, carefully think on each step performed and watch what actions are common to every example.
- Make a list of variable elements, specifying their magnitude and measurement units. Associate them proper symbols or names but take care of avoid their repetition
- Which principles or relationships apply to the problem?
- Write down the selected relationships but using your own variables (symbols or names). If needed, describe equations with words.
- Are all variables in use? Are there as many relationships as unknown variables?
- Are you using all the information available in the problem statement? If not, select just the important.
Guide 4
- Describe your solution qualitatively (you can start by making a narration.)
- Make some predictions regarding the expected result based only upon the description you made. Do not assume anything that is not in your description.
- Make the required relationships and check that the result comes from the selected variables. (Keep in mind the measurement units.)
- Substitute values (with their corresponding signs and units) at the end of your development of relationships.
- Transform your description into an algorithm (pseudocode or flowchart). Remember, the algorithm must ask unknown values, show main results and store (in variables) the results of relationships and formulas.
Guide 5
- Manually compute the result (i.e. perform a hand-trace.) If needed, draw plots that describe the behavior of the variables.
- Follow strictly each step of the algorithm and look at the results. (Someone else can perform this step.)
- Are all your predictions from 4.2 accomplished? Measurement units are preserved?
- Do the units make sense?
- Is reasonable the order of magnitude of results?
- Does it work for boundary values?
- Do every variable has an initial value?
- Interpret the result to write down an explanation of it (how it was produced) and assign units.
Copyright © 2002-2007 Jorge Vasconcelos. Johns Hopkins
University,
Department of Computer Science.
Return to the CS106
Homepage