INTRODUCTION TO PROBLEM SOLVING
- Problem solving is a process of transforming the description of a problem into the solution of that problem by using our knowledge of the problem domain and by relyingon our ability to select and use appropriate problem-solving Strategies, Techniques and Tools.
- Problem solving (with in the context of developing programs) refers to analyzing a problem with theintention of derivinga solution for the problem.
- Software development method(SDM).
Consists of the followingsteps:
- Requirementsspecifications (Specification of needs).
- Problem analysis.
- Design the algorithmto solve the problem.
- Implementation.
- Testing and verification.
- Documentation.
- Requirements Specifications:
- State the problemclearly and unambiguously (Doubtless) to understand exactly:
- What the problemis?
- What is neededto solve it?
- What the solutionshould provide
- If there are constraints and special conditions.
- ProblemAnalysis:
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 applesgiven the numberof kilograms (kg) of applespurchased and the cost perkg 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 differentinterpretations to it).
- It must be general (it can be used for different Inputs).
- Writing the algorithmis a difficult task use top-down design (Divide and Conquer approach).