Lecture 2
Lecture 2
Introduction
Not all problems can be solved with a computer system. Categories of problems that cannot
be solved with a computer system are called non computable problems while problems that
can be solved with a computer system are called computable problems
In this study session, you will be introduced to the introduction to problem solving methods
which comprise four steps: understanding the problem, designing a plan, executing the plan
and evaluating the plan. Also, seven main steps of problem solving will be discussed in the
study session as well.
2.1 Define the concept of Problem Solving and itemize the four levels involved in problem
solving
Problem solving involves analysing a problem and deducing a way to solve the problem. The
problem to be solved can come from any real world problem or even an abstract world. Hence,
there is a need for a standard and systematic approach to solving problems. Problems in the field
of computing can either be computable or non-computable.
A computable problem is a problem that can be solved using principles of computing while non-
computable problems are problems that cannot be solved using any principles of computing
b. Devising a plan
Once the problem is understood, one must devise the plan of action to solve the problem. A
plan is formed by proceeding from the data to the result according to the relationship that
links them. If the problem is trivial, this step will not require much thinking. General
techniques include the following:
c. Executing the plan
Once the plan is defined, it should be followed completely. Each element of the plan should be
checked as it is applied. If parts of the plan are found to be unsatisfactory, the plan should be
revised.
Finally, the result should be examined in order to make sure that it is valid and that the
problem has been solved.
Problem solving involves analysing a problem and deducing a way to solve the problem.
To illustrate this step, let’s take a simple non-computer problem such as the recipe for
Cream Horns. Based on this recipe, we can break down the problem into three sub-problems:
ALGORITHM
PSEUDOCODE FLOWCHART
Figure 2.1: Representations of Algorithm
2.3: PSEUDOCODE
Algorithms can also be represented with a flow chart but a simple approach to this is to first
represent it as a pseudo-code, then converting the pseudo-code to a flowchart.
Example 2.1
Consider an electrician trying to replace burnt out box with new ones. To replace the burnt
bulb, he must first check if the bulb is burnt or not. If it’s burnt, he replaces the bulb, else
leaves the bulb. To solve this problem, the electrician wrote down the pseudo-code and the
flowchart he needs in order to solve the problem. The pseudo-code for the problem is
represented as follows:
START
STOP
Figure 2.2: Flowchart Representation of Bulb Replacement Problem
Considering the definitions of pseudo-code and flowchart given above identify the major
similarities and differences between pseudo-code and flowchart.
2.2.4 Testing Strategy Development
Now that the detailed steps for solving the problem has been done. There is a need to testing the
algorithm from the first step to the last step of a set of instructions that can be understood by the
computer. This involves testing the strategy development of a program in any high level
programming language of your choice. For all test cases, the expected results must be computed
and specified before proceeding to the next step. Complete test cases can then be used to check
algorithms and programs efficiently.
The pseudo-code produced by solution refinement, in Step 3, is used as a blueprint for the
program. Depending on the programming language used, program will be used and testing
should follow in order to meet up with requirements of our problem solving.
2.2.6 Documentation
Here, documentation should begin with the first step of program development and continues
throughout the lifetime of the program. A program’s documentation must include the
following:
iii. The problems that were encountered during the writing and testing of the program.
The final documentation must also include a printed copy of the program, called a program
listing. This listing should be made readable by careful layout as one does with a technical
report, which is what the written form of the program really is: a written description of the
computer solution of the problem. Programs can be made easier to understand by the reader if
all of their complex parts include explanations in the form of comments.
Later, when the program must be changed, these explanations will make the changes easier to
implement. To be complete, the documentation must include some user instructions. For
programs that will be used by people unfamiliar with computers, it is necessary to include a
user’s manual that explains, without using technical jargon, how to use the program, how to
prepare the input data and how to interpret the program’s results.
When you run the same program a thousand of times, some of the hardware components of the
computer may wear out and need maintenance but the program can’t wear out. However, a
program can work properly nine hundred and ninety-nine times and then fail during the
thousandth run.
This may give the appearance that the program has worn out, but actually the program
encountered an unusual set of circumstances.
In other words, the program did not fail because it had worn out, it failed because it did not
work properly to begin with; it was never tested for this particular set of circumstances. If
the unusual circumstances had occurred on the first run instead of the thousandth, the program
would have failed on the first run. Thus, program maintenance is largely completing the
process of implementation.
5. Steps involved in problem Solving are: Program Definition, Definition Design, Solution
Refinement, Testing Strategy Development, Program coding and testing, Documentation
Completion and Program Maintenance.