Problem Solving Concept by Meetendra Sir (Unit 5)
Problem Solving Concept by Meetendra Sir (Unit 5)
INTRODUCTION
A problem obstructs and hinders the progress or movement
in achieving of an objective.
The nature of the problem depends on the situation.
In problem solving each individual may have his or her own
unique way.
PROBLEM DEFINITION
Problem definition is the first and most important step in
determining information needs.
Information needs of software can be determined by:
1.
2. Using questionnaires
3. Stating the tentative information needs
4. Suggesting interpretation of information needs with
users.
2. BRAINSTORMING METHOD
Brainstorming is a group activity designed to increase the
quantity of fresh ideas.
or
Brainstorming is a group method for obtaining new ideas and
business solutions.
The groups are organized for sitting together and stimulate
greater creativity by exchange of mutual experiences and
participating in the discussions.
The brainstorming ideas are canalized to a particular
segment of product line or services.
10
A Problem of Size
n (Instance)
Subproblem 1 of
Size n/2
Subproblem 2 of
Size n/2
A Solution to
Subproblem 2
A Solution to
Subproblem 1
A Solution to the
Original Problem
Divide-and-Conquer Strategy
11
1.
12
What to do ?
2. How to do ?
This phase answer the first question.
Here, the programmer has to defined the task
precisely(correctly) and check for completeness.
There should not be any ambiguity(confusion).
13
14
15
16
3. EXPLORE SOLUTION
When programmer complete the analysis then he/she will
explore (or design) the different solution of the problem
and the best or optimum solution is chooses by the
development team.
17
18
19
ALGORITHMS
An algorithm is any well-defined computational procedure
that takes some value, or set of values, as input and
produces some value, or set of values, as output.
20
Algorithm
Input
Computer
Output
Notion of Algorithm
MEETENDRA SINGH CHAHAR
21
22
Format of an Algorithm
Input:
Step 1:
Step 2:
Step 3:
..
..
..
Step n:
Output:
23
Characteristics of an Algorithm
Finiteness: Terminates after a finite number of steps.
Definiteness: Rigorously and unambiguously specified.
Input: Valid inputs are clearly specified.
Output: Can be proved to produce the correct output given
a valid input.
Effectiveness: Steps are sufficiently simple and basic.
24
Advantages of an Algorithm
Provides step by step procedure to understand easily.
Algorithm is easy to write.
Solves those problems which are complex and not solve by
simple methods.
Algorithm in general, can be directly coded in a
programming language.
25
Step 1: START
Step 2: Initialize x, y and z
Step 3: Read x, y
Step 4: Calculate z = x + y
Step 5: Print Sum of two numbers, z
Step 6: STOP
26
FLOWCHARTS
A flowchart is a graphical representation of an algorithm.
or
A flowchart is a diagram that is prepared by the
programmer which represents the sequence of steps
involved in solving a problem.
It is an aid to solve a complex problem easily and
efficiently.
It is also used to correct and debug a program flow after
the coding part is completed.
To be continued
27
28
Flowchart Symbols
In constructing flowcharts, standard symbols are used.
The American National Standard Institute(ANSI) symbols
are normally used.
Some important flowchart symbols are given here:
29
Symbols
Name(Attribute)
Process
Terminator
Decision
Delay
Description
An operation or action step.
A start or stop point in a process.
A question or branch in the process.
A waiting period.
Data(I/O)
Alternate
Process
Flow Line
Flowchart Symbols
30
Symbols
Name(Attribute)
Predefined
Process
Document
A document or report
Multi-Document
Preparation
Display
Description
A machine display
Manual Input
Stored Data
Flowchart Symbols
31
Symbols
Name(Attribute)
Description
Punched Tape
Merge (Storage)
Extract
(Measurement)
Magnetic Disk
(Database)
A database
Direct Access
Storage
Flowchart Symbols
32
Initialize sum
& Read x, y
sum = x +y
Print sum
STOP
MEETENDRA SINGH CHAHAR
33
PSEUDO CODE
Pseudo code is an artificial and informal language that helps
programmers to develop algorithms.
Pseudo code is a text-based detail (algorithmic) design
tool.
It is a compact and informal high-level description of a
computer programming algorithm that uses the structural
conventions of a programming language, but is intended for
human reading rather than machine reading.
Pseudo code typically omits details that are not essential
for human understanding of the algorithm, such as variable
declaration, etc.
To be continued
MEETENDRA SINGH CHAHAR
34
35
else statements
end-if
To be continued
MEETENDRA SINGH CHAHAR
36
Use = or
For example
i = j or i
37
38
Step 4:
max = a[i]
Step 5:
Endif
Step 6: Endfor
Step 7: Return max
39
TIME COMPLEXITY
Time Complexity of an algorithm is the amount of computer
time it needs to run to completion.
This is the sum of compile time and run time.
Some of the reasons for studying time complexity are:
1.
40
f(n) O(g(n))
41