Problem Solving
RealGulraiz
/RealGulraiz
Ch#1 - Problem Solving
Overview
Problem Solving Steps
Flowcharts
Algorithm
Verification & Validation
Identification and Correction of Errors
RealGulraiz
Problem Solving?
Identifying the problem
&
Finding best solution
RealGulraiz
1.1 Problem Solving Steps
01 Defining a Problem
02 Understanding a Problem
03
Planning a Solution
04 Defining Candid Solutions
05 Selecting the Best Solution
RealGulraiz
1.1.1 Defining a Problem
Well-defined Problem:
● Does not contain
ambiguities
● Clearly specified conditions
● Clear Goal
● Easy to understand & solve
RealGulraiz
1.1.1 Defining a Problem
If the problem is not defined well then
use one of following strategies:
● Gain Background Knowledge
● Use Guesses
● Draw a Picture
RealGulraiz
1.1.1 Defining a Problem
Gain Background Knowledge
● Try to know the situation
● Identify the given state
Outcomes:
● How a good solution will look like?
● How to measure the the solution?
RealGulraiz
1.1.1 Defining a Problem
Use Guesses
● Try to guess unknown information
● Appropriate guesses
How?
● Based upon past experiences.
RealGulraiz
1.1.1 Defining a Problem
Draw a Picture
● Draw a picture
● Fill the undefined information
Remember,
● Pictures speak louder than words
RealGulraiz
Albert Einstein
“If I were given one hour to
save the planet, I would
spend 59 minutes defining
the problem and one
minute resolving it.”
Next Topic
Understanding a Problem
RealGulraiz
Step#2
Understanding a Problem
It is important to
understand the
problem before
jumping into the
solution.
Why?
Understanding a Problem
Helps to save:
● Money
● Time
● Resources
Problem Solving
Understanding a Problem
● Understanding a Problem usually includes Problem
Analysis.
● Problem Analysis is the process to figure out 5 W’s from a
problem statement.
Problem Solving: Understanding a Problem
5 Ws
● What
● Who
● Why
● When
● Where
Problem Analysis
Case Study
Suppose your class teacher
assigns you a task to prepare a
list of students in your school
whose names start with letter
'A'. The list is required in order
to prepare an alphabetical
directory of all school students
and there is only one week to
complete the task.
● What
● Who
● Why
● When
● Where
Step#1
Defining a Problem
Step#5
Selecting the
Best Solution
Step#2
Understanding a
Problem
Step#4
Defining Candid
Solutions
Step#3
Planning a
Solution
Problem
Solving
Next Topic
Planning a Solution
RealGulraiz
Step#1
Defining a Problem
Step#5
Selecting the
Best Solution
Step#2
Understanding a
Problem
Step#4
Defining Candid
Solutions
Step#3
Planning a
Solution
Problem
Solving
RealGulraiz
Step#3
Planning a Solution
Step#3: Planning a Solution
Formulate a “plan”
that lead you
towards the
solution
Major Action:
Finding right
“strategy” for
problem solving
RealGulraiz
Strategies:
● Divide & conquer
● Guess, Check and Improve
● Act it out
● Prototype
RealGulraiz
Step#3: Planning a Solution
RealGulraiz
Divide and Conquer
● Divide complex problem into
smaller problems
Why?
● It is easy to solve sub-problems
Step#3: Planning a Solution
RealGulraiz
Guess, Check and Improve
● Designer guesses a solution
● Then checks the correctness of
that solution
● Refines the solution
○ Iterative process
Step#3: Planning a Solution
RealGulraiz
Act it out
● Define list of “to-do” tasks
● Then perform these tasks
Step#3: Planning a Solution
RealGulraiz
Prototype (Draw)
● Draw a pictorial representation
of the solution
● It may help designer to
understand important aspects of
solution
● Divide & conquer
● Guess, Check and Improve
● Act it out
● Prototype
Selection of Strategy?
“Depends upon the problem”
RealGulraiz
Next Topic
Defining Candid Solutions
RealGulraiz
Step#1
Defining a Problem
Step#5
Selecting the
Best Solution
Step#2
Understanding a
Problem
Step#4
Defining Candid
Solutions
Step#3
Planning a
Solution
Problem
Solving
RealGulraiz
Step#4
Defining Candid Solutions
Step#4: Defining Candid Solutions
Candid?
● Spontaneous
Or
● Unplanned
RealGulraiz
RealGulraiz
Candid Solution
● One can think of a “candid
solution” anytime
● It is not necessarily “actual
solution”
Step#4: Defining Candid Solutions
RealGulraiz
Advantages
● Save Time
● Quick Analysis
Step#4: Defining Candid Solutions
RealGulraiz
Example
● Number of students in
your school who can play
cricket?
○ CANDID SOLUTION?
Step#4: Defining Candid Solutions
Step#1
Defining a Problem
Step#5
Selecting the
Best Solution
Step#2
Understanding a
Problem
Step#4
Defining Candid
Solutions
Step#3
Planning a
Solution
Problem
Solving
RealGulraiz
Step#5
Selecting the Best
Solution
Step#5: Selecting the Best Solution
Multiple Solutions
● Sometimes we find
more than one
solutions of a problem
Then?
● Select the best one
RealGulraiz
Step#5: Selecting the Best Solution
Example#1
● Problem: Search a particular
student name on school’s
website
Possible Solutions
● Solution 1: Take printouts and
search the required name
● Solution 2: Press Ctrl+F, Type
the name to search
automatically.
RealGulraiz
Step#1
Defining a Problem
Step#5
Selecting the
Best Solution
Step#2
Understanding a
Problem
Step#4
Defining Candid
Solutions
Step#3
Planning a
Solution
Problem
Solving
RealGulraiz
Next Topic
Flowcharts
RealGulraiz
Find these lectures on

Problem Solving Steps in Computer Science - RealGulraiz Youtube Tutorials