Problem Solving and Computer Programming, Peter Grogono &
Sharon H Nelson, © 1982 Addison-Wesley Publishing Company Inc. Reproduced by the permission of the publisher.Overview of Two Methods 11
Pseudocode Guidelines 11
Flowchart Elements 13
It is considered good practice for a single flowchart never to exceed the bounds of one page. If a flowchart does not fit on one page, this is one instance in which the better solution is to use refinement which results in the creation of subprograms. Subprograms on separate pages are more desirable than using a connector to join flowcharts over more than one page. A flowchart expressing the solution to an involved problem may have the main program flowchart on one page with subprograms continuing the problem solution on subsequent pages. An example of this situation is given in the last solved problem in this document — the Auto Teller problem on page 54.Programming Structures 14
An Example Using Sequence 17
Pseudocode 17
Flowchart 18
Binary Selection 18
Multi-way Selection 21
Examples Using Binary Selection 22
7TN Pseudocode 22
Flowchart 22
Pseudocode 22
Flowchart 22
An Example Using Multi-way Selection 23
Pseudocode 23
Flowchart 23
Repetition: Pre-Test 23
Repetition: Post-Test 25
An Example Using Pre-Test Repetition 25
Pseudocode 26
Flowchart 27
An Example Using Post-Test Repetition 27
Pseudocode 27
Flowchart 27
Example of Using Subprograms in Pseudocode 30
Example of Using Subprograms with one Parameter in Pseudocode 32
Solved ProblemsTable Indicating Programming Structures Used in the Sample Problems 2
Lift Problem 3
Pseudocode 3
Flowchart 3
73^ Pseudocode 4
Temperature Control Problem 5
TZiS Pseudocode 5
Toll Gate Problem 8
Pseudocode 9
Subprogram 11
'Squash' Scoring Problem 13
Pseudocode 13
Subprogram 15
Record Separation Problem 16
7TN Pseudocode 17
7TN Pseudocode 20
73^ Pseudocode 23
Flowchart 24
Guess the Number Problem 25
7TN Pseudocode 26
Subprogram 28
Income Tax Problem 30
Pseudocode 30
Another valid method of solving this problem is to use the multiple selection or ‘case’ structure.Telephone Dialler Problem 32
TTN Pseudocode 33
Subprogram 36
Auto Teller Problem 37
7TN Pseudocode 38
Subprograms 43
Algorithms for Searching 2
Pseudocode 3
Flowchart 4
General Idea of the Algorithm 5
7TN Pseudocode 6
END SUBPROGRAM calculate the Middle positionAlgorithms for Sorting 7
General Idea of the Algorithm 7
7TN Pseudocode 8
General Idea of the Algorithm 9
Pseudocode 9
General Idea of the Algorithm 12
Pseudocode 13
Flowchart 14