Docsity

Problem Solving: Algorithms and Program Development, Exercises of Software Development

Partial preview of the text

Download Problem Solving: Algorithms and Program Development and more Exercises Software Development in PDF only on Docsity!

Session 8

Introduction to Problem Solving

Objectives

  • Basic concepts of problem solving
  • Steps involved in program development
  • Top-down programming

Problem solving

  • It’s a creative process, it is an act of
    • Defining a problem
    • Determining the cause of the problem
    • Identifying, prioritizing, and selecting alternative for a solution
    • Implementing a solution

Strategies for problem solving

  • There is no universal method for solving a given

problem

  • Different strategies are good for different problems
  • Some of the well-known strategies are
  • Divide and conquer
  • Greedy method
  • Dynamic programming
  • Backtracking
  • Branch and Bound

Alternatives Evaluation Matrix

  • An Alternatives Evaluation Matrix can be used

to compare alternatives for numerous

requirements including hardware, software,

databases, operating systems, or languages.

  • A Weighted Alternatives Evaluation Matrix,

assigns weighting factors to criteria when

comparing alternatives.

Sample of Alternatives Matrix

PROGRAM DEVELOPMENT STEPS

Steps in Program Development

  • The various steps involved are
    • Defining or Analyzing the problem
    • Design (Algorithm)
    • Coding
    • Documenting the program
    • Compiling and running the program
    • Testing and Debugging
    • Maintenance

Tasks in defining a problem

  • Followings are the tasks in order to define a

problem

  • Specifying the input requirements
  • Specifying the output requirements
  • Specifying the processing requirements

Specifying the input requirements

  • The input specification is obtained by

answering following questions

  • What specific values will be provided as input to the program?
  • What format will the values be?
  • For each input item, what is the valid range of values that it may assume?
  • What restrictions are placed on the use of these values?

Specifying the processing requirements

  • The processing requirement is obtained by

answering following questions

  • What is the method (technique) required in producing the desired output?
  • What are the validation checks that need to be applied to the input data?
  • What calculations are needed?

Activity: Find Factorial Number

  • Input?
  • Output?
  • Process?

Design

  • A design is the path from the problem to a

solution in code

  • The well designed program is likely to be:
    • Easier to read and understand later
    • Less of bugs and errors
    • Easier to extend to add new features
    • Easier to program in the first place

Design