CSE Problem Solving Process
CSE Problem Solving Process
We face problems in our day-to-day life. Problem in this sense is one that can be solved
using computers.
In solving a problem, we may get various solutions. But all solutions involve the
following formal problem solving steps.
There are various methods to find these specifications, like interview, observations, or for
simpler problems in written form, read the requirements carefully
This and the next steps of the problem solving process are computer independent works.
Divide the original problem into a number of sub problems. These sub- problems,
being necessarily smaller than the original problem, are easier to solve and their
solution will be the components of our final solution. This method, by which a
complex problem is divided into smaller and easier sub-problems is called “divide
and conquer”
Associating each task with a precise method to accomplish it, which consists of a
sequence of well defined steps which, when carried out, perform the
corresponding task. This sequence of steps is called and Algorithm
Algorithms are usually developed in pseudo code or using flowchart. Pseudo code is a
language used to describe the manipulations to be performed on data. This language is a
simple mixture of natural language and mathematical notations and it is independent of
programming language.
Example: the pseudo code to calculate tax deduction of employees based on the
following requirement:
For salary more than 500 birr, tax is 5% of the
salary, and for salary less than 500 birr, tax is 3% of the salary. The
pseudo code for this requirement may look like the
following
Input salary
If salary > 500 birr
set tax to salary * 0.05
Else
set tax to salary * 0.03
Output tax
Planning is sketching the step-by-step activities that lead to the solution. This is
formulating a problem in terms of the steps to its solution.
Pseudo code or flow chart algorithms cannot be executed (performed) directly by the
computer. They must first be translated into programming language, a process referred to
as coding.
It is expressing the solutions (in the previous step) in one of the various programming
language.
There are many high-level programming languages like BASIC, COBOL, Pascal,
FORTRAN, C, C++, VB, etc. To get our program work, we write it based on the syntax
rules of the programming language.
Syntax rule: correct way of writing or expressing commands that direct the control of the
computer system.
It is very rare that a program can be written correctly the first time. Most programmers
get used to the idea that there are errors in their newly written programs, these errors are
detected during testing the program, and appropriate revision must be made and the tests
return.
5. Documentation
This activity starts with the first step of defining the problem and continues. It is
compiling related documents throughout the lifetime of the program development. The
documentation must include
Though there can be many solutions (various programs) for one problem (requirement),
we should select the best one based on its reliability, maintainability, portability, and
efficiency (time & space).
Algorithm is a finite set of well-defined rules (statements) for the solution of a problem in
a finite number of steps. To design an algorithm for a problem first we break down the
problem into simpler and manageable tasks. For one problem there may be a lot of
algorithms that help to solve, but the algorithms that we select must be powerful, easy to
maintain, and efficient (doesn’t take too much space and time)
The most common ways to represent algorithms include pseudo code and flowchart. A
flow chart consists of an ordered set of standard symbols (mostly geometrical shapes),
which represent operations, data flow or decision.
Start
Read salary
[No] [Yes]
Salary
>=500
tax = sal *0.03 tax = sal * 0.05
Display tax
end
Loops
[Initialization]
true
[Compute]
[Increment]
The above simple structure tells that execution continues as far as the test holds true.
Example
Flowchart to find factorial of a given number
i.e. factorial of a given number n is: n x [n-1] x [n-2] x … x 1
START
ctr = ctr -1
input fact
ctr = fact
[NO]
ctr> display fact
0
[YES]
END
Fact= fact*ctr