0% found this document useful (0 votes)
12 views16 pages

Problem Solving Techniques

The document outlines the fundamental concepts of problem solving, including definitions, strategies, and the steps involved in program development. It emphasizes the importance of understanding a problem before attempting to solve it and details various methodologies such as top-down programming and algorithm design. Additionally, it covers the stages of coding, documentation, testing, and maintenance necessary for effective program development.

Uploaded by

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

Problem Solving Techniques

The document outlines the fundamental concepts of problem solving, including definitions, strategies, and the steps involved in program development. It emphasizes the importance of understanding a problem before attempting to solve it and details various methodologies such as top-down programming and algorithm design. Additionally, it covers the stages of coding, documentation, testing, and maintenance necessary for effective program development.

Uploaded by

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

Problem Solving

Techniques
Introduction
We will get to know the following -
❖ Basic concepts of problem solving
❖ Advantages of top-down programming approach
❖ Steps involved in program development
Problem Solving Aspect
Definition:-

It is a creative process and it is an act of defining a problem, determining the cause of the problem,
identifying, prioritizing and selecting alternatives for a solution and implementing a solution.

A problem can be solved successfully only after making an effort to understand the problem. To
understand the problem we need to answer the following questions-

● What do we know about the problem?


● What is the information that we have to process in order to find the solution?
● What does the solution look like?
● What sort of special cases exists?
● How can we recognize that we have found the solution?
Problem Solving Aspect
There is no universal method for solving a given problem. Some of the strategies available for solving a
given problem are -

● Divide and Conquer -


● Greedy Method -
● Dynamic Programming
● Backtracking
● Branch and Bound
Problem Development Steps
The various steps involved in program development are:

❏ Defining or Analysing the problem


○ The problem is defined by doing a preliminary investigation. Defining a problem helps us to
understand the problem clear. It is also known as Program Analysis.
Tasks in defining a problem-

✓ Specifying the input requirements


✓ Specifying the output requirements
✓ Specifying the processing requirements
○ Specifying the input requirements - Determine the inputs required and source of the
data. The input specification is obtained by answering the following questions:
✓ What specific values will be provided as input to the program?
✓ What format will the values be?
✓ For each input what is the range of values?
✓ What restrictions are placed on the use of these values?
Problem Development Steps
○ Specifying the output requirements - Describe in detail the output that will be
produced. The output specification is obtained by answering the following questions:
✓ What values will be produced?
✓ What is the format of these values?
✓ What specific annotation, headings or titles required in the report?
○ Specifying the processing requirements - Determine the processing requirements for
converting the input data to output. The processing specification is obtained by
answering the following questions:
✓ What is the method / technique required in producing the desired output?
✓ What calculations are needed?
✓ What are the validation checks that need to be applied to the input data?
Problem Development Steps
○ Design(Algorithm) - A design is the path from the problem to a solution in code. Program design is
both a product and a process. This phase deals with the operations to be performed during solving
the problem. Algorithms, flowcharts and pseudocodes are some of the design techniques.
✓ A well designed program is more likely to be :
1. Easy to read and understand
2. Less of bugs and errors
3. Easy to extend to add new features
4. Easy to program
✓ Modular Design - Once the problem is designed clearly, several design methodologies can be
applied. An important approach is Top-Down programming design. It is a structured design
technique which breaks up the problem into a set of subproblems called modules and creates
a hierarchical structure of modules.
Problem Development Steps
✓ While applying top-down design consider the following-
1. A problem is divided into smaller logical subproblems called modules
2. Each module should be independent and should have a single task to do
3. Each module should have only one entry point and exit point so that logic flow of the program is
easy
4. When the program id executed it must be able move from one module to another in sequence
until all the modules are executed
5. Each module should be of manageable size in order to make the design and testing easy
✓ Top-down design has the following advantages-
1. Breaking up the problem into parts helps us to clarify what is to be done
2. At each step of refinement, the new parts become more focussed and therefore easier to design
3. Modules may be reused
4. Breaking the problem into parts allows more than one person to work on the solution
simultaneously

Problem Development Steps
○ Algorithm - An algorithm is a step by step description of the solution to a problem. It is
defined as an ordered sequence of well-defined and effective operations which when carried
out for a given set of initial conditions, produce output and terminate in a finite time.
Characteristics of an Algorithm:-

✓ Input - It may accept a zero or more inputs


✓ Output - It should produce at least one output (result)
✓ Definiteness - Each instruction must be clear, well defined and precise.
✓ Finiteness - It should be a sequence of finite instructions. It should end ina fixed time
and should not enter into an infinite loop.
✓ Effectiveness - This means that operations must be simple and are carried out in a
finite time at one or more levels of complexity.
✓ Implementation independent (Independent of Programming language)
Problem Development Steps
○ Flowchart - This is a chart showing the flow of logic involved in solving a problem. Flowchart
can be defined as a diagrammatic representation of an algorithm. It is referred as a blueprint
of an algorithm. It is an easy way to understand and analyze the problem.
Flowcharts are classified into two types namely, Program flowcharts and System flowcharts.

Flowcharts make use of geometrical figures, to specify a particular operation. The following table
shows different geometrical figures used in program flowchart . While drawing a flowchart the
operations must be written inside the figures.

Start and Stop Decision Continuation


Making

Input and Repetition /


Output Looping

Processing Connections
Problem Development Steps
○ Pseudocode - A Pseudo code is neither an algorithm nor a program. It is an abstract form of
a program. It consists of English like statements which perform specific operations.
For Example:- Write a pseudo code to perform the basic arithmetic operations.

read n1 , n2
sum = n1 + n2
diff = ni - n2
mult = n1 * n2
quot = n1 / n2
print sum, diff, mult, quot
End
○ Coding - An algorithm expressed in programming languages is called Program. Writing a
program is called Coding. The logic developed in the algorithm is used to write the program.


Problem Development Steps
○ Documenting the program- Documentation explains how the program works and how to
use the program. Documentation can be of great value not only to those who are involved in
maintaining or modifying the program but also for the programmers themselves. Details of a
particular program are easily forgotten without suitable documentation.
Documentation comes in two forms:

✓ External Documentation - which includes things such as reference manuals, algorithm


descriptions, flowcharts and project workbooks.
✓ Internal Documentation - which is part of the source code itself ( declarations,
comments, statements)
Problem Development Steps
○ Compiling and Running the program - Compilation is a process of translating a source
program into machine understandable form. The compiler is system software, which does
the translation after examining each instruction for its correctness. The translation results in
the creation of object code.

After compilation, Linking is done if necessary. Linking is the process of putting together all
the external references that are required by the program. The program after this process is
ready for execution.

During execution, the executable object code is loaded into computer’s memory and the
program instructions are executed.
Problem Development Steps
○ Testing and Debugging - Debugging is the process of detecting and correcting errors (mistakes)
in the program. There is a program called the debugger that takes an object program as input and
executes it and helps in eliminating the mistakes that occur in source program.
Three types of errors occur generally. They are

1. Syntax Errors
2. Logical Errors
3. Run-time Errors
Syntax Errors - These type of errors are the result of violation of the grammar (rules of the
programming language). On encountering these errors the computer displays an error message
specifying the line number where the error has occurred.

Logical Errors - These occur during the coding process. When the programmer codes the
problem, he must take care of correct operations to be performed. The program will be executed
but produce wrong results. It is difficult to debug these errors.
Problem Development Steps
Run-time Errors - These type of errors occur when we attempt to run the ambiguous
instructions. For example, an infinite loop in a program sequence which causes no output. They
also occurs due to device errors, improper sequencing of constructs, errors in system software,
incorrect data input etc., The computer will print the error message like “Divide by zero”.

○ Testing - Testing is the process of executing a program with the deliberate intent of finding errors.
It is needed to check whether the expected output matches the actual output. Program should be
tested with all possible input data and control conditions.

Testing is done during every phase of program development. Initially, requirements can be tested
for its correctness. Then the design can be tested for its exactness and efficiency.

Programs are tested with several test criteria -

2. Test whether each and every statement in the program is executed at least once
3. Test whether every branch in the program is traversed at least once
4. Test whether the input data flows through the program and is converted to an output.
Problem Development Steps
○ Maintenance - Program require a continuing process of maintenance and modification to keep
pace with changing requirements and technologies. Maintainability of the program is achieved by
✓ Modularizing it
✓ Providing proper documentation for it.
✓ Following standards and conventions (naming conventions, using symbolic constants
etc)

You might also like