Heuristic Methods Used in Programming

Total Page:16

File Type:pdf, Size:1020Kb

Heuristic Methods Used in Programming

Heuristic Methods Used in Programming

Terminology Defined  Heuristics: an analytical and logical approach to problem solving that often uses algorithms to solve problems that don’t have clear-cut solutions such as playing chess and programming a computer.  Algorithm: is a set of sequential instructions that are followed to solve a problem. Algorithms are often written in Pseudocode and can be displayed symbolically in a flowchart. (See example handout)  Pseudocode: expresses an algorithm (Al Gore has no rhythm) in everyday English, rather than in a programming language.  Flowchart: Complicated algorithms are best illustrated with symbols in a flowchart. A flowchart shows the actual flow of the logic of a program, whereas a structure chart simply contains statements of the levels of refinement used to reach a solution. The meanings of different flowchart symbols can be observed on page 27 in the Basic Programming Today textbook. (See example handout)  Warnier Orr diagram: is another method of graphically outline the logical flow of a program. This method utilizes series of large and small brackets { } to denote the flow and hierarchical level of procedures or subroutines in a larger program. This method can be cumbersome and will be used sparingly in this class.  Structure Chart: graphically represents stepwise refinement used in top-down and bottom-up design, and shows the relationship between the subtasks or parts of a larger process of program. Sample structure can be seen on page 24 fig. 2-2 in the BPT textbook.  Top-down design: a methodology for solving a problem whereby you first state the problem and then repeatedly subdivide (or refine) the problem into manageable subproblems.  Stepwise refinement: is the process of repeatedly subdividing tasks into subtasks until each remaining subtask is easily solved. A level of refinement identifies each of successive subdivision.  Refinement levels: Level 0 is the main problem. Level 1 contains the first level of refinement or group of subtasks. Level 2 contains the second level of refinement or group of subtasks, and so on. There can be as many levels of refinement as needed to break a problem into manageable subproblems.  Bottom-design: is a method of problems solving that proceeds from the specific to the general whereas the top-down design proceeds from the general to the specific. Top-Down vs. Bottom-Up Design  Top-down design aims to design a program that meets the user’s specific needs. Typically the programmer determines what is wanted and starts writing code from scratch.  Bottom-up design typically starts with an existing program or part of a program and attempts to modify it to meet a programming need other than that for which it was originally intended.  Top-down design initially requires considerable time working out the logic, but in the long run it leads to more efficient use of the programmer’s time and makes the process of debugging easier.  The advantage of the Bottom-up method is that it uses materials already created (code written by some other nerd). It allows the programmer to start programming immediately. Don’t reinvent the wheel so to speak.  A disadvantage of the Bottom-up method is that it can become more time- consuming than starting from scratch if major modifications are required to meet the specific needs of the user.  Typically a combination of these design methods are utilized when writing programs.

Recommended publications