0% found this document useful (0 votes)
32 views12 pages

01_COS102_Introduction_to_Problem Solving

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
32 views12 pages

01_COS102_Introduction_to_Problem Solving

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 12

COS 102: INTRODUCTION TO

PROBLEM SOLVING
(LECTURE NOTE)

COURSE DESCRIPTION
This course is designed to equip you with the skills
needed to solve problem in a broad range of fields. It
lays more emphases on the appropriate problem
solving skills a computer scientist or a programmer
may need for the execution of variable range of
tasks.
After the completion of this course, you are expected
to know the following problems solving concepts:
• Problem solving strategies
• Role of algorithm in problem solving process
• Implementation strategies
• Concepts of algorithm
• Properties of algorithm
Prerequisite: A background in COS 101:
Introduction to computer science and AEFUNAI-
CSC101: Introduction to Basic computer skills for
Beginners or any other related course(s) is essential.
CONTENTS

1.0 Introduction
1.1. General Problem Solving Strategies
1.2. Concepts of Algorithm
1.2.1.Major Components of Algorithm
1.2.2.Properties of Algorithm
1.2.3.Role of Algorithm in Problem Solving
1.2.4.Ways of expressing Algorithm
1.2.5.Algorithm Development Methodologies
1.2.5.1.Top-Down Design
1.2.5.2.Object Oriented Design
2.1Implementations strategies
2.1.1.Problem requirements (Requirement Specification).
2.1.2.Analyze the problem (Analysis)
2.1.3.Design the algorithm to solve the problem (Design).
2.1.4.Implement the algorithm (Implementation).
2.1.5.Test and verify the completed program (Testing).
2.1.6.Maintain and update the program (Maintenance).
2.2.Applications of Software Development Methods in Problem Solving
3.1.Brief Introduction to C Programming Language
CASE STUDY I: Algorithm and Programming Examples
USE CASE II: Examples
Summary
Exercises Error! Bookmark not defined.
References
1.0. Introduction to Problem Solving
There is no day that passes in the life of any human
without problem solving. In our day to day activities
we purchase things from the market, make
transactions, withdraw money from the banks, pay
school fees or hostel/lodge fees, prepare for lectures,
prepare and cook our foods, calculating the total
expenses and the amount each student will pay if
they go for excursion, etc. All these activities are
some kind of problem solving.
In problem solving, we follow a kind of organized
procedure. The reason most people encounter
difficulty in their lives or endeavour is that they fail
to follow an organized procedure or they fail to plan.
A recipe provides a good example of a plan. The
ingredients and amounts are determined by what is
to be prepared; the output determines the input and
the processing. The recipe often reduces the number
of mistakes you might make if you tried cooking
with no plan at all.
Many first time programmers try to write programs
without making a careful plan. It is observed that
you will spend little time working on a program if
you devise a careful thought out step-by-step plan
before actually writing the program.

Problem solving is a compound word that is


composed of two words, “Problem” and “Solving”.
For us to give a definition we need to take the words
into context. Depending on the context, problem has
been defined in a number of ways.

The dictionary definition holds that:


• Problem is a question raised for inquiry,
consideration or solution.
In mathematics:
• Problem is defined as a situation that is to be
resolved using well-defined mathematical
principles.
Solving on the other hand can be defined as a means
of finding solution to a problem.
We can define problem solving as the sequential
process of analyzing information related to a given
situation and generating appropriate response
options. This definition actually suits problem
solving but partly to the context of computing. This
is because computers are limited in its problem
solving capabilities. Although a computer is a very
powerful and versatile machine yet it has no
intelligence.
A computer performs many tasks exactly in the
manner as instructed or directed by the programmer.
Hence, most of the responsibilities of programming
are placed on the user to instruct the computer in a
correct and precise form so that the machine is able
to perform the required job in a proper manner.

In order to instruct a computer correctly, the user


must have a clear understanding of the problem to be
solved. Problem solving is a process which is an
integral part of work and life; it is the means of
reaching a desired situation from a current situation.

However, once a problem has been analyzed and


instruction translated into program, the computer has
the ability to carry out the processing in a very fast,
repeated and consistent manner for different data
entry and variable situations.
1.1. General Problem Solving
Strategies
To solve a problem, one has to understand what the
problem is, to avoid mistakes or incorrect
assumptions.
To be a better problem solver, we need to have a
good understanding of the general problem-solving
framework.
One of the frameworks is the one outlined by
George Polya in his book “How to solve it”. This
problem solving approach, even though was written
for mathematical problem solving has been widely
adopted in computing and many other problem
solving domains.
The four Polya’s problem solving strategies are:

1. Understanding the problem: Carefully read the


problem to understand what needs to be
accomplished. Assess your background skills in
the area under consideration to know if you have
to acquire more skills in other to solve the
problem. Visualize the final-result and use it as a
guide in determining the validity of your solution
and the result that will be obtained. Identify the
known and the unknown (variables). Check the
data and the conditions that need to be satisfied.
Check to know if the condition is sufficient to
determine the unknown. Split the problem into
parts and write down the parts.
2. Device a plan: here, you come with a way to
solve the problem. Check to see if there is a link
between the data and the unknown (variable), if
there is no link then try using auxiliary problem.
Check if a similar problem exists so you can
adapt the solution instead of wasting time with
what has been in existence. After all, the
outcome of this phase is the plan of the solution.
3. Carrying out the plan: This is where you solve
the problem you came up with in your 'devise a
plan' step. In carrying out the plan, you have to
go through the steps to know if they are correct,
ascertain if there is any missing link. Check if the
correctness of the plan can be proved. If the plan
does not work correctly, discard it and try
another plan.
4. Looking Back: This is the moment of reflection.
Basically, check to see if you used all your
information and that the answer makes sense.
This is the phase that you can crosscheck what
you have done to arrive at the present stage. In
this phase, you can ascertain what worked and
what did not work. This is the time your
argument and results are verified for correctness
and consistency. In this phase, you can check if
the solution can be applied in other problems. At
this point, you can also ascertain if you can still
get the same result using different methods.

1.2. Concepts of Algorithm


Problem solving as we have seen involves the
abstraction and decomposition of large amount of
problem into smaller manageable subtasks that can
be handled independently.
An algorithm is important in the planning and
execution of a problem solution since it specifies the
sequence of steps needed to carry out the
instructions that will lead to the overall result.

An algorithm can be defined as a sequential set of


instructions that are followed in other to solve a
problem using a finite amount of data in a finite
amount of time.
More than one algorithm can be written for a
particular problem (see figure 1.0) but the choice of
selecting a particular algorithm in place of the other
is dependent on the following factors:
• Reliability
• Accuracy
• Ease of modification and
• Time required for the execution when converted
to a high-level language.

Figure 1.0: Relationship between Problem, Algorithms and Programs

When there are multiple algorithms for a particular


problem, the best algorithm is typically the one that
solves it the fastest.
As computer programmers, we are constantly using
algorithms, whether it's an existing algorithm for a
common problem, or if it's a completely new
algorithm unique to our program. By understanding
algorithms, we can make better decisions about
which existing algorithms to use and learn how to
make new algorithms that are correct and efficient.

Why study an Algorithm?


Computer scientists learn by experience. We learn
by seeing others solve problems and by solving
problems by ourselves. Algorithms are often quite
different from one another. As we study algorithms,
we can learn analysis and techniques that allow us to
compare and contrast solutions based solely on their
own characteristics, not the characteristics of the
program or computer used to implement them.

Difference between Algorithm and Program


Algorithm Program
Does not require a computer Requires the computer for
for execution. executions.
Can be expressed in various Is written in specific
natural languages or pseudo programming languages
code. understood by computers.
Used to generate a solution Designed to be executed by
to any given problem in the a computer to perform a
form of steps. particular task or set of
tasks.
Can be easily translated to May have limited
different programming
portability depending on the
languages or implemented programming language or
on different platforms. platform used.
Emphasis on the conceptualEmphasis on the
understanding of a problemimplementation and syntax
solving approach. of the programming
language.
May not produce an output Produces a defined output
or result directly. or result as specified by the
program.

1.2.1. Major Components of Algorithm


Most of the algorithms used in solving program
related problems consist of three major sections:
Input, processing and output.
That is the summary of most if not all the activities
undertaken by most algorithms in other to produce a
result.
To execute a task, the algorithm requires some data
(i.e. input), performs some computation on the data
(i.e. processing), then it produces result (i.e. output).

The processing comprises of any or all of the


following: computation, selection, iteration, etc. The
figure below shows the three major sections of an
algorithm.

Figure 1.1: The three major sections of an Algorithm

Input: This represent the data that is to be sent for


processing in the system. Most algorithms provide
some variables and the description of the data that
the variable will handle.

Processing: This is the action performed on data in


other to produce the desired result. Such actions like
computation, selection, iteration, etc.

Output: This is the result produced after the data


has been processed. When the algorithm has been
converted to programs, the data is usually displayed
through the output device, for example the monitor.

You might also like