0% found this document useful (0 votes)
47 views6 pages

1.2 Problem Solving Strategies

The document outlines the key steps in the problem solving process: 1) defining requirements and analyzing the problem, 2) designing an algorithm to solve the problem using techniques like top-down design, pseudo code and flowcharts, 3) implementing the algorithm in a programming language, 4) testing and verifying the program works as intended, and 5) documenting the overall process. It provides examples to illustrate each step, such as calculating total apple costs given inputs like quantity and price.

Uploaded by

Kalai Suresh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views6 pages

1.2 Problem Solving Strategies

The document outlines the key steps in the problem solving process: 1) defining requirements and analyzing the problem, 2) designing an algorithm to solve the problem using techniques like top-down design, pseudo code and flowcharts, 3) implementing the algorithm in a programming language, 4) testing and verifying the program works as intended, and 5) documenting the overall process. It provides examples to illustrate each step, such as calculating total apple costs given inputs like quantity and price.

Uploaded by

Kalai Suresh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

1.

2 PROBLEM SOLVING STRATEGIES:

Problem solving is a process of transforming the description of a problem into the solution of that problem by
knowledge of the problem domain and by relying on our ability to select and use appropriate problem-solving
strategies, techniques and tools.
Problem solving (within the context of developing programs) refers to analyzing a problem with the intention of
deriving a solution for the problem.

It consists of the following steps:

- Requirements specifications (Specification of needs).


- Problem analysis.
- Design the algorithm to solve the problem.
- Implementation.
- Testing and verification.
- Documentation.

REQUIREMENTS SPECIFICATIONS:
State the problem clearly and unambiguously (Doubtless) to understand exactly:
• What the problem is?
• What is needed to solve it?
• What the solution should provide
• If there are constraints and special conditions.
PROBLEM ANALYSIS:
In the analysis phase, we should identity the following:

• Inputs: To the problem, their form and the input media to be used.
• Outputs: Expected from the problem, their form and the output media to
be used.
• Special constraints or (necessity) conditions (if any).
• Formulas or equations to be used.

Example:

Problem: Compute and display the total cost of apples given the number of kilograms (kg) of apples
purchased and the cost per kg of apples.
• Input: Quantity of Apples purchased (in kg).
• Cost per kg of Apples (in Rs. per kg).
• Output: Total cost of Apples (in Rs.).
• Constraint: N/A
• Formula: Total cost = Cost per kg x Quantity.
DESIGN THE ALGORITHM TO SOLVE THE PROBLEM:
Purpose: To develop and verify algorithm.

An algorithm is a list of steps to be executed with the right order in which these steps should be executed.
An algorithm must satisfy these requirements:

- It must have and Input.


- It must have an Output.
- It must not be ambiguous (there should not be different interpretations to it).
- It must be general (it can be used for different Inputs).
- Writing the algorithm is a difficult task use top-down design (Divide and Conquer approach).

TOP-DOWN DESIGN:

1.List the major steps (most algorithm consists of at least the following):

- Get the data.


- Perform the computations.
- Display the result.

2. Perform algorithm refinement the step(s) may need to be broken down into a more detailed list of steps.

3. Verify that the algorithm works as intended – perform desk check.

- It must be correct and it must solve the problem for which it is designed.
- It must execute and terminate in a finite amount of time.
- It must be efficient enough so that it can solve the intended problem using the resource currently
available on the computer.

An algorithm can be represented using Pseudo codes (or) Flow charts.

- Specifying the order in which the steps are to be executed is important.

Example:

Algorithm for getting out of bed and prepare to go to work.

- Get out of Bed.


- Take Shower.
- Get Dressed.
-
If a same steps are performed in a slightly different order:

- Get out of Bed.


- Get Dressed.
- Take Shower.
-
What would be the result?

PSEUDO CODE:
Pseudo code is semiformal English – like language with limited vocabulary that can be used to design and
describe algorithms.

Criteria of a good pseudo code:

- Easy to user stand, precise and clear

- Gives the correct solution in all cases

- Eventually ends

FLOWCHART:

Flowchart is a graph used to depict or show a step by step solution using symbols which represent a task. The
symbols
used consist of geometrical shapes that are connected by flow lines .It is an alternative to pseudo coding, where as a
pseudo code description is verbal. A flowchart is graphical in nature.

The symbols:

Terminal: the beginning and end points of an algorithm.

Process: shows an instruction other then i/p, o/p or selection.

Input-output: shows an input or an output operation.

Disk storage i/o: indicates i/p from or o/p to disk storage.

Printer output: shows hard copy printer output.

Selection: shows a selection process for two-way selection.

Off- page connector: its provide continuation of a logical path on another page.

On-page connector: its provide continuation of a logical path on another point in

the same page.

→ Flow lines: indicate the logical sequence of execution steps in the algorithm.
Any algorithm can be described using only three control program structures:

1. Sequence.
2. Selection.
3. Repetition.

SEQUENCE CONTROL STRUCTURE:


A series of steps or statements that are executed in a specific order. The beginning and end of a block of
statements can be optionally marked with the keywords begin and end.
The structure:
Statement 1
Statement 2
Statement 3

Example:
Begin
Read birthdate
Age=today’s date - birth date
Print age

End

SELECTION CONTROL STRUCTURE:

- Defines two courses of action depending on the outcome of a condition


- A condition is an expression that is either true (or) false.
- The keyword used are if and else.
Example:

If age>55
Print “ ”
Else
Print “ ”
Endif
If (marks>=60)
Printf(“passed\n”);
Else
Printf(“failed\n);
If else structure:

REPETITION CONTROL STRUCTURE:

- specifies a block of one or more statements that are repeatedly executed until
a condition is satisfied

- Key word used is while


While structure:

While<termination condition>
Statements

IMPLEMENTATION:

The process of implementing an algorithm by writing a computer program using a programming


language (Example: using ‘c’ language)

The output of the program must be the solution of the intended problem.

TESTING AND VERIFICATION:

The program testing is the process of executing a program to demonstrate its correctness. Program
verification is the process of ensuring that a program meets user requirement. After the program is compiled
run the program and test/verify it with different inputs before the program can be released to the public or
other users.
Example:

Input Expected Output Actual Output


2 8.00
4
50
2.5 125.00

DOCUMENTATION:

It contains details produced at all stages of the program development cycle. It can be done in 2 ways

- Writing comments between your lines of codes.

- Creating a separate text file to explain the program.

It is important not only for other people to use or modify the program, but also to understand the own
program after a long time.

*********************************************************************************

You might also like