Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

INTRODUCTION TO Problem Solving: Ppa (Unit - 5)

Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

PPA (UNIT - 5)

INTRODUCTION TO Problem Solving


In general, in our daily life ,we face a variety of problems that may be
related to any field. The same problem can be solved in different way by
different person and the techniques used for the solution by someone
may be correct.

 The nature of the problem depends on the situation.


 Problem solving may be an art or science.It includes special
knowledge in the fields to which the problem relates to and power
of knowledge without learning,human reasoning and experience.
 In problem solving each individual may have his or her own
unique way.
Therefore ,prior to the solution of any problem one should follow the
following basic steps that may give a clear and better idea for the
solution of any problem:
Framework for problem solving:
STEP1: Understanding the problem
In this step you should try to understand the actual problems by asking
the following basic questions:
 Can you state the problems in your own words?
 What are you trying to find or do?
 What are unknowns?

(UNIT-4 ) PPA Notes by: Mansi Tyagi


STEP2: Devising a Plan/Making a plan of solution
Its very useful to prepare a good plan for the solution of given problems:
 Look for a pattern
 Examine related problems.
 Make a table,diagrams & equation if required
 Use quess and check

STEP3: Carrying out the plan


Implement the strategies in step 2 and perform any necessary actions or
computations.This may be a formal proof of each step.finally keep an
accurate record of your work for further use.
STEP4: Looking back/Verifying
After successful carrying out the plan,following should be checked:
 Check the results in the original problem.
 Interpret the solution in terms of the original problem.

PROBLEM SOLVING TECHNIQUES

TRIAL AND ERROR BRB11


BRAIN STORMING DIVIDE & CONQUER
TECHNIQUES
TECHNIQUES TECHNIQUES

(UNIT-4 ) PPA Notes by: Mansi Tyagi


1. TRIAL AND ERROR TECHNIQUE//METHOD :
Some complex problems can be solved by a technique that is called trial
and error.Trial and error is typically good for problems where you have
multiple chances to get the correct solution.
 The purpose of trial and error is not to find out why a problem was
solved.its primarily used to solve the problem.

 Trial and error is used to find a single solutions to a single


problem.

 Trial and error is used best when it is applied to situations that give
your large amounts of time and safety to come up with a solution.
For example :while trial and error may be excellent in finding solutions
to mechanical or engineering problems.

Advantages :
 It does not require you to have a lot of knowledge.
 It also plays an important role in the scientific method as well.
 Trail and error is also an excellent tool for inventors.

2. BRAIN STORMING TECHNIQUES :


“Brainstoring is a group method for obtaining new ideas and business
solutions.The groups are organized for sitting together and stimulate

(UNIT-4 ) PPA Notes by: Mansi Tyagi


greater creativity by exchange of mutual experiences and participating in
the discussions.”

 Brainstorming can be an effective way to generate lots of ideas on


a specific issue and then determine which ideas is the best solution.
 It is most effective with groups of 8-12 people and should be
performed in a relaxed environment.If participants feel free to
relax and joke around,they will stretch their minds further and
therefore produce more creative ideas.
For example: It is commonly used for advertising,the development
of new products,process management and business planning.

There are four basic rules in brainstorming :


1. No Criticism : Criticism is reserved for the evaluation stage of
the process.This allows the members to feel comfortable with
the idea of generating unusual ideas.
2. Welcome unusual ideas :Unusual ideas are welcomed as it is
normally easier “tame down” than to “tame up ” as new ways of
thinking and looking at the world may provide better solutions.
3. Quantity wanted: The greater the number of ideas
generated,the greater the chance of producing an effective
solution.
4. Combine and improve ideas: combine ideas in order to make
them better.

Advantages :

 Encouraged creative thinking


 All ideas are accepted.
(UNIT-4 ) PPA Notes by: Mansi Tyagi
 Makes everyone part of team
 Easy and simple technique.

STEPS OF BRAINSTORMING :

Define the problem /Explain the topic

Set a time limit

Encourage Ideas

Records the ideas

Clarifying

Evaluate ideas

Create possible solution

3. DIVIDE AND CONQUER TECHNIQUES :


In the technique,the main problem is divided into several smaller sub
problems and then it is solved recursively.At last combine these
solutions to create the solution of the original problem.
Divide and conquer approach normally follow the following
steps-

(UNIT-4 ) PPA Notes by: Mansi Tyagi


 Divide : Divide the original problem into a set of sub problems
 Conquer : Solve each sub problem individually and recursively
if required.
 Combine: Finally, combine the solutions of the sub problems
into a solution of the entire original problem.

Divide and conquer strategy

PROBLEM OF SIZE “n”

Subproblem 1 of size n/2 Subproblem 2 of size n/2

Solution to Subproblem 1 Solution to Subproblem 2

Solution to the
Original Problem

(UNIT-4 ) PPA Notes by: Mansi Tyagi


Seven Steps to Problem Solving

Define and Identify the problem

Analyze the problem

Identifying possible solutions

Selecting the best solutions

Evaluate Solutions

Develop an Action Plan

Implement the Solution

1.Define & identify the problem:


The first step is critical .its essential for each group member to
cearly understand the problem so that all energy will be focused in the
same direction.
2.Analyze the problem :
In this stage of problem solving, questions should be asked and
information gathered. Do not make the mistakes of assuming you know
what is causing the problem without an effort to fully investigate the
problem you have defined.

(UNIT-4 ) PPA Notes by: Mansi Tyagi


3.Identifying possible solution:
Identifying possible solutions to the problem is sometimes referred
to as finding “Optional solutions” because the goal is to complete a list
of all conceivable alternatives to the problem.
4. Selecting the best solution:
Decision making can be seen as bringing one into an ambivalent
relationship with both power and responsibility.
5.Evaluating Solutions:
There are several ways to evaluate the chosen solution,and writing
them all down will help the group to choose the best solution to the
problem.
6. Develop an Action Plan:
An action plan is a chart that lists the tasks that need to be done
and identifies who will be responsible for each,when and what action is
necessary ,where to start,and how.

 Divide the solution into sequential tasks


 Develop the contingency plans.

7.Implement the solution :


Showing that the problem solving process organized and orderly
process will convince others that the solution is valid.

(UNIT-4 ) PPA Notes by: Mansi Tyagi


ALGORITHM
A algorithm is a procedure or formula for solving a problem.It can
defined as a step-by-step procedure to solve a particular problem or
program.

 An algorithm is a sequence of finite instructions used for


calculations and data processing.
 It’s a type of effective method in which a lsit of well-defined
instructions for completing a task will,when given an initial
state,proceed through a well defined series of successive
states,eventually terminating in an end-state.

 Five Characterstics of Algorithm :


1.Input: It may accept zero or more input.
2.Output: It should produce at least one output.
3.Definiteness:Each instruction must be clear ,well defined and
precise.There should not be an ambiguity.
4.Finiteness: It should be a sequence a finite instructions i.e;it should
end after a fixed time.
5.Effectiveness: Steps are sufficiently simple and basic.
 Notations for algorithm:
1.Name of the algorithm
2.Step numbers
3.Explanatory comment
4.Termination

(UNIT-4 ) PPA Notes by: Mansi Tyagi


 Essential properties of an algorithm :
 It must be concise
 It must be unambiguous
 It must be simple
 It should lead to a unique solution of the problem
 It must be capable of machine execution
 Advantages :
 Easy to debug
 It is independent of programming languages.
 It has a definite procedure.
 Disadvantages:
 It is cumbersome and time consuming

 Example 1: Write an algorithm to determine a student’s final


grade and indicate whether it is passing or failing. The final grade
is calculated as the average of four marks.
Step 1: Start
Step 2: Input M1,M2,M3,M4

Step 3: GRADE  (M1+M2+M3+M4)/4


Step 4: if (GRADE < 50) then
Print “FAIL”
else
Print “PASS”
Step 5: Stop

(UNIT-4 ) PPA Notes by: Mansi Tyagi


 Example 2: Write an algorithm that reads three numbers and
prints the value of the largest number.

Step 1: Start
Step 2: Input N1, N2, N3
Step 3: if (N1>N2) then
if (N1>N3) then
[N1>N2, N1>N3]
else
[N3>N1>N2]
endif
else
if (N2>N3) then
[N2>N1, N2>N3]
else
[N3>N2>N1]
endif
endif
Step 4: Print “The largest number is”, MAX
Step 5 : Stop

(UNIT-4 ) PPA Notes by: Mansi Tyagi


 Example 3:To print pascal triangle (Important algo.)
Step1:START
Step2:Read n
Step3: For i=1 to n in steps of 1
Begin
For i=1 to (n-i)in steps of 1
Begin
Print “ “
I=i+1
End
For k=1 to (k<i)in steps of 1
Begin
Print k
K=k+1
End
For k=i to 1 in steps of 1
Begin
Print k
K=k-1
End
Print from new line
i=i+1
End
Step4: STOP

(UNIT-4 ) PPA Notes by: Mansi Tyagi


Pseudo Code: is an artificial and informal language that helps
programmers develop algorithms. Pseudo code is very similar to
everyday English.
 Example 1: Write an algorithm to determine a student’s final
grade and indicate whether it is passing or failing. The final grade
is calculated as the average of four marks.
Pseudo code:
 Input a set of 4 marks
 Calculate their average by summing and dividing
by 4
 if average is below 50
Print “FAIL”
else
Print “PASS”

(UNIT-4 ) PPA Notes by: Mansi Tyagi


Flowchart
A Flowchart
 shows logic of an algorithm
 emphasizes individual steps and their interconnections
 e.g. control flow from one action to the next
 Flow chart is diagrammatic representation of an algorithm. It is built using
different types of boxes of symbols. The operation to be performed is
written in the box. All symbols are interconnected by arrows to indicate the
flow of information and processing.

Following are the standard symbols used in drawing flowcharts.

Oval Terminal Start/stop/begin/end


symbol

Parallelogram Input/Output Making data available for


processing (input) or
recording of the
processed
information(output)

Rectangle Process Any processing to be


performed. An
assignment operation
normally represented by
this symbol

Diamond Decision Decision or switching type


of operations that
determines which of the

(UNIT-4 ) PPA Notes by: Mansi Tyagi


alternative paths is to be
followed.

Circle Connecter Used for connecting


different parts of flow
chart.

Arrow Flow Joins two symbols and


also represents
executions flow.

 `Advantages:
 Communication: flowcharts are better way of
communicating the logic of a system to all concerned.
 Effective analysis: with the help of flowchart problem
can be analyzed in more effective way.
 Proper documentation
 Efficient coding
 Proper debugging
 Efficient program maintenance
 Disadvantages:
 Complex logic
 Alternativess and modifications
 Reproductions
 Time-consuming
 Subjective

(UNIT-4 ) PPA Notes by: Mansi Tyagi


 Example :Draw a flowchart that will read the two sides of a
rectangle and calculate its area.

Complexity
It is very convenient to classify algorithms based on the relative amount
of time or relative amount of space they require and specify the growth
of time/space requirements as a function of the input size.
TYPES OF COMPLEXITY ARE:
1.SPACE COMPLEXITY
2. TIME COMPLEXITY

(UNIT-4 ) PPA Notes by: Mansi Tyagi


1. Space complexity:
Space complexity of an algorithm is the amount of memory it needs to
run to completion.
S(x)= c+Sx
S(x) is the space required by a problem x
C is a constant
Sx is an instance characterstic

2.Time Complexity :
Time complexity of an algorithm signifies the total time required by the
program to run to completion. The time complexity of algorithms is
most commonly expressed using the big O notation.
Time Complexity is most commonly estimated by counting the number
of elementary functions performed by the algorithm. And since the
algorithm's performance may vary with different types of input data,
hence for an algorithm we usually use the worst-case Time
complexity of an algorithm because that is the maximum time taken for
any input size.
Some of the reasons for studying time complexity are:
 We may be interested to know in advance that whether an
algorithm/program will provide a satisfactory real time response.
 There may be several possible solutions with different time
requirements.

(UNIT-4 ) PPA Notes by: Mansi Tyagi


Types of Notations for Time Complexity
Now we will discuss and Big Oh denotes "fewer than or the same as" <expression>
iterations.

1. Big Omega denotes "more than or the same as" <expression> iterations.

2. Big Theta denotes "the same as" <expression> iterations.

3. Little Oh denotes "fewer than" <expression> iterations.

4. Little Omega denotes "more than" <expression> iterations.

Understanding Notations of Time Complexity with Example


 O (expression) is the set of functions that grow slower than or at the same rate
as expression.
 Omega (expression) is the set of functions that grow faster than or at the same
rate as expression.
 Theta (expression) consist of all the functions that lie in both O(expression) and
Omega expression.

(UNIT-4 ) PPA Notes by: Mansi Tyagi


Big Oh Notation
Big-oh notation is the formal method of expressing the upper bound of
an algorithm’s running time. It is the measure of the longest amount of
time it could possibly take for the algorithm to complete.
We have O(f) called big-oh,which represents the class of functions that
grow no faster than f.
It is used in computer science to describe the performance or complexity
of an algorithm.

Use of Big Oh Notation

Big oh notaion has two main areas of application:

 In computer science, big oh notation is used to classify algorithms


by how they respond to changes in input size.
 In mathematics, big oh notation is used to describe the limiting
behaviour of a unction when the argument tends towards a
particular value or infinity, usually in terms of simpler functions.
 It is also used in many other fields to provide similar estimates.

(UNIT-4 ) PPA Notes by: Mansi Tyagi


IMPORTANT QUESTIONS

Q1. Describe the relevance and importance of problem solving


techniques.
Q2. What do you understand bythe pseudocode?
Q3. What is divide and conquer techniques to solve a problem?Explain
it by giving an example.
Q4. Write the short note on brainstorming?
Q5. Discuss the different techniques for problem solving with help of
examples?
Q6. Explain various steps involved in problem solving?
Q7. What is big-oh notation? Explain its use.

Q8. Explain the algorithm? What are five characterstics of an algorithm?


Q9.Draw a flowchart to find highest common factor(H.c.f) of two given
numbers m and n.
Q10. What is flowchart?Explain its symbols by designing a flowchart
for finding whether give number is prime or not?
Q11. Why time complexity is an important issue?Explain.
Q12. How flowchart ,algorithm,program &pseudo codes are different
from each other ?Also enumerate their individual importance and
relevance.Write them all for generating a sine series.

(UNIT-4 ) PPA Notes by: Mansi Tyagi

You might also like