UNIT 1: Introduction to Problem Solving
Objectives:
This unit will:
1. Introduce computer programming.
2. Introduce you to problem solving in computing.
3. Explain the steps involved in problem solving with an example.
4.. Provide problem sets to practice.
Computer programming is the process of specifying the data types and the operations for a
computer to apply data in order to solve a problem.
Data types are different kinds of actions that can be stored and manipulated in a computer program.
E.g integers, numbers, characters, boolean values.
Operations are different kinds of actions you can perform on data in order to manipulate them.
Common/Arithmetic operations: addition, subtraction, division and multiplication.
Comparison operations: Greater than (>), less than (<), equal to (==), not equal to (!=), greater
than or equal to (>=), and less than or equal to (<=).
Logical operations: AND, OR, and NOT.
Etc
We write a program using programming languages.
Program is a set of codes that tells and instruct the computer what task to perform and how to
perform them.
Programming languages are languages through which we can instruct the computer to carry out
some processes and tasks. It’s a way of communication between the computers and humans.
1.0 Introduction
The word “problem” simply means an unsatisfactory situation or a gap found in a situation. Thus,
a problem may be a desire to improve over an existing condition or to block an existing loophole.
For example, once upon a time, distance communication was only possible through the exchange of
letters. A person from Katsina would write a letter to a person in Lagos. The person in Lagos would
write a letter to respond to the person in Katsina. We can see this mode of distance communication
as a problem in many ways.
On the other hand, the “solving”, as the word implies, is an act of addressing an issue by providing a
new solution to a situation or an improvement over an existing solution. For example, for the
problem outlined above, the first generation (1G) landline telephone communication had, in some
way, solved it by providing instant communication. In this case, the 1G technology had filled a gap
that existed in distance communication. Over the years, second generation (2G) mobile technology
was introduced empowering people to communicate while they are mobile and thereby improving
over the 1G.
The essence of problem solving is to provide you with the reasoning and analytical skills to
understand a problem and also provide a solution to the problem. In the context of computing,
problem solving can be defined as the study of a problem and also providing a solution to the
problem. The study of a problem involves understanding it (the problem) and being able to extract
useful data for the potential solutions. To solve a problem, one must have an understanding of the
problem; otherwise, the solution may be inaccurate. Hence, solving a problem begins with the
precise identification of the problem and ends with a complete working solution.
1.1 Problem Solving Steps
The Key steps required for solving a problem are highlighted below.
1) Understanding the problem
Every solution has a specific problem that it addresses. In order to provide a solution, you need
to know what problem you are providing it for. In other words, you cannot provide a solution
to a problem you do not understand. Hence, it is important to clearly understand a problem
before we begin to find the solution for it. If we are not clear as to what is to be solved, we may
end up developing a solution which may not solve the problem. Thus, we need to understand a
problem first.
2) Analyzing the problem
After understanding the problem, we need to break down the problem into smaller components.
This will aid in extracting useful information and identifying principal components of the
problem. By analyzing a problem, we would be able to figure out what are the inputs that our
solution should accept and the outputs that it should produce.
3) Developing an Algorithm
After a clear understanding and analysis of the problem, we need to devise an algorithm for the
solution. Algorithms are a step-by-step process to follow in order to arrive at a solution to the
problem. We will discuss more on Algorithms later. For now, imagine an algorithm as a very well-
written manual for solving a given problem, with clearly defined steps that, if followed, one will
end up at a solution to the problem. We start with a tentative solution plan and keep on
improving the plan until the algorithm is able to capture all the aspects of the desired solution.
For any given problem, there is a possibility of having more than one algorithm, and we have to
select the most suitable algorithm.
4) Programming After finalizing the algorithm, we need to convert the algorithm into the
format which can be understood by the computer to generate the desired solution. We use
programming languages to do this conversion. You can think of programming language as a
technology use for the implementation of a well-defined steps (algorithm), required to solve a
problem, into a computer readable format, so that it can be executed by a computer.
5)Testing and Debugging
After the programming phase we need to check that our program solves the problem in which it
was written for accurately, without misbehaving in any form. The program created should be
tested on various parameters. It must respond within the expected time. It should generate correct
output for all possible inputs. In the presence of syntactical errors, no output will be obtained.
In case the output generated is incorrect, then the program should be checked for logical errors,
if any.
The following is a problem statement and how to apply the problem solving steps to create a solution
for the problem.
1.2 Problem Statement 1
The country of Rigbee is currently experiencing an epidemic of Joker Virus, the country is made up
of two states, North Rigbeeand South Rigbee. There are health care centres within each of the states
for the virus patients to receive adequate treatment. Unfortunately, some of the patients die while
some survive. Information about the health situation concerning the joker virus is usually from
several versions of rumours. The accuracy of information, such as number of patients, patient on
admission, discharged or died are questionable. There is need for accurate information in order for
the general public to know the current health situation and also for the government to make better
informed decisions.
Applying the problem solving process to the problem will involve following the below steps.
Step 1 Identify the problem: This will require you to read the above problem statement
thoroughly. From the above statement you may understand that the problem is an inaccurae
information system. Information is usually distributed from different versions of rumors, which
may not be consistent.
Step 2 Analyze the problem: This will require you to have a second look at the problem statement.
During this phase you will want to note down some key things that will aid in creating your
algorithm. Key things like:
· Number of states in the country:2
· Data to be collected from each state health center: Number of patients, Number of
patients on admission, Number of dead patients and Number of Discharged patients.
After noting down the key things, you may begin to think about the output of the solution. The
output will be the aggregate of the
· Number of patients in all the 2 states.
· Number of patients on admission in all the 2 states.
· Number of dead patients in all the 2 states.
· Number of Discharged Patients in all the 2 states.
Step 3 Develop an algorithm: After you have analysed the problem to identify the key things,
input, and output, you may begin to think of how to devise a solution to the problem. The
algorithm may be in the form of a written step by step instruction that will lead to the required
solution.
Step 4 Programming: In this stage, you need to translate your algorithm into computer
understandable format using your chosen programming language.
Step 5 Testing and Debugging: This stage is usually during and after the programming stage, the
stage requires you to ensure that your solution is working as it should, without any error or
misbehavior at any [Link] subsequent sections shall provide the algorithm and programming
code to solve the preceding problem statement.