Introduction To Problem Solving
Introduction To Problem Solving
Today, computers are all around us. We use them for doing various tasks
in a faster and more accurate manner. For example, using a computer or
smartphone, we can book train tickets online.
Computers are used for solving various day-to-day problems and thus
problem solving is an essential skill that a computer science student
should know. Computers themselves cannot solve a problem. Precise
step-by-step instructions should be given by us to solve the problem.
Thus, the success of a computer in solving a problem depends on how
correctly and precisely we define the problem, design a solution
(algorithm) and implement the solution (program) using a programming
language. Thus, problem solving is the process of identifying a problem,
developing an algorithm for the identified problem and finally
implementing the algorithm to develop a computer program.
Problem Solving Steps
1. Identify the problem. The first step in solving any problem is to first identify it. This stage
requires analysis of the current situation, identification of the problem, evaluating why the
problem is occurring, and assessing who the problem is affecting. This stage also involves looking
at any contributing factors that are directly influencing the problem and where they are coming
from.
2. Look for solutions. The next step in solving a problem is to generate several possible solutions
that could remedy the issue. This step often involves brainstorming, prediction, and forecasting
and is sometimes done with two or more people. Complex problems are rarely able to be solved
by a single solution, so coming up with several potential interventions is the key to success in this
stage.
3. Choose a solution. Once you’ve come up with several potential solutions that could potentially
solve the problem, you’ll now need to carefully analyze each solution and select the most
appropriate one. This step can take some trial and error, as not all solutions are obvious. This step
also requires strong decision-making skills, especially when there are multiple solutions on the
table.
Problem Solving Steps
4. Implementation of the solution. After one solution has been chosen, it’s now time to
implement this solution to the problem. There should be clearly established benchmarks that will
show whether the solution is working along with a plan in case the solution doesn’t work.
5. Monitoring progress. After the solution has been implemented, progress must be monitored to
ensure the solution is effective. You can monitor how well the solution is working as well as ask
for feedback from others who are directly affected by the changes that were made. Based on
feedback and progress, adjustments may need to be made to continue seeing progress.
Algorithm
An algorithm is a process or set of rules which must be followed to complete a
particular task.
This is basically the step-by-step procedure to complete any task.
All the tasks are followed a particular algorithm, from making a cup of tea to
make high scalable software.
This is the way to divide a task into several parts.
If we draw an algorithm to complete a task then the task will be easier to
complete.
The algorithm is used for,
To develop a framework for instructing computers.
Introduced notation of basic functions to perform basic tasks.
For defining and describing a big problem in small parts, so that it is very easy
to execute.
Algorithm
Characteristics of Algorithm
1. An algorithm should be defined clearly.
2. An algorithm should produce at least one output.
3. An algorithm should have zero or more inputs.
4. An algorithm should be executed and finished in finite number of steps.
5. An algorithm should be basic and easy to perform.
6. Each step started with a specific indentation like, “Step-1”,
7. There must be “Start” as the first step and “End” as the last step of the
algorithm.
Algorithm
Let’s take an example to make a cup of tea,
Step 1: Start
Step 2: Take some water in a bowl.
Step 3: Put the water on a gas burner.
Step 4: Turn on the gas burner
Step 5: Wait for some time until the water is boiled.
Step 6: Add some tea leaves to the water according to the requirement.
Step 7: Then again wait for some time until the water is getting colorful as tea.
Step 8: Then add some sugar according to taste.
Step 9: Again, wait for some time until the sugar is melted.
Step 10: Turn off the gas burner and serve the tea in cups with biscuits.
Step 11: End
Algorithm
Advantages of Algorithm
An algorithm uses a definite procedure.
It is easy to understand because it is a step-by-step definition.
The algorithm is easy to debug if there is any error happens.
It is not dependent on any programming language
It is easier for a programmer to convert it into an actual program because the
algorithm divides a problem into smaller parts.
Disadvantages of Algorithms
An algorithm is Time-consuming, there is specific time complexity for different
algorithms.
Large tasks are difficult to solve in Algorithms because the time complexity
may be higher, so programmers have to find a good efficient way to solve that
task.
Looping and branching are difficult to define in algorithms.
Flow Chart
A flowchart is a visual representation of an algorithm. A flowchart is a diagram
made up of boxes, diamonds and other shapes, connected by arrows. Each shape
represents a step of the solution process and the arrow represents the order or link
among the steps. There are standardized symbols to draw flowcharts.
Write an algorithm to find the square of a
number.
Before developing the algorithm, let us
first identify the input, process and output:
• Input: Number whose square is required
• Process: Multiply the number by itself to
get its square
• Output: Square of the number
Algorithm to find square of a number.
Step 1: Input a number and store it to num
Step 2: Compute num * num and store it
in square
Step 3: Print square
Pseudocode
A Pseudocode(pronounced Soo-doh-kohd) is defined as a step-by-step
description of an algorithm. Pseudocode does not use any programming
language in its representation instead it uses the simple English language text
as it is intended for human understanding rather than machine reading.
Pseudocode is the intermediate state between an idea and its
implementation(code) in a high-level language.
INPUT num1
INPUT num2
COMPUTE Result = num1 + num2
PRINT Result
Flow of Control
It basically analyzes and chooses in which direction a program flows based on
certain parameters or conditions. There are three basic types of logic, or flow
of control, known as:
• Sequence logic, or sequential flow
• Selection logic, or conditional flow
• Iteration logic, or repetitive flow
Sequential Logic (Sequential Flow)
Sequential logic as the name suggests follows a serial or sequential flow in
which the flow depends on the series of instructions given to the computer.
Unless new instructions are given, the modules are executed in the obvious
sequence.
Flow of Control
Selection Logic (Conditional Flow)
Selection Logic simply involves a number of
conditions or parameters which decides one If (condition) then:
out of several written modules. [Module A]
The structures which use these type of [End of If structure]
logic are known as Conditional Structures.