Docsity

Problem Solving: A Guide to Analyzing & Solving Problems with Algorithms & Flowcharts, Study Guides, Projects, Research of Programming Languages

Partial preview of the text

Download Problem Solving: A Guide to Analyzing & Solving Problems with Algorithms & Flowcharts and more Study Guides, Projects, Research Programming Languages in PDF only on Docsity!

Lecture 05: Problem Solving

  • (^) Basic concepts of problem solving
  • (^) Steps involved in program development
  • (^) Top-down programming
  • (^) Programming languages, their types, and features

Objectives

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 Strategies for problem solving
  • (^) The problem is defined by doing a preliminary

investigation

  • (^) Defining a problem helps us to understand problem

clearly

  • (^) It is also known as Program Analysis Analyzing or Defining the Problem
  • (^) Followings are the tasks in order to define a problem
    • (^) Specifying the input requirements
    • (^) Specifying the output requirements
    • (^) Specifying the processing requirements

Tasks in defining a problem

  • (^) 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 are required in the report?
  • (^) What is the amount of output that will be produced? Specifying the output 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? Specifying the processing requirements
  • (^) Input : Positive integer number
  • (^) Output : Factorial of that number
  • (^) Process : Solution technique which transforms input to

output. Factorial of a number can be calculated by the

formula n!=123…n

Activity Find Factorial Number

  • (^) Use case diagrams are used to gather the requirements of a system
  • (^) So when a system is analyzed to gather its functionalities use cases are prepared and actors are identified.
  • (^) The purposes of use case diagrams can be as follows:
    • (^) Used to gather requirements of a system
    • (^) Used to get an outside view of a system
    • (^) Identify external and internal factors influencing the system
    • (^) Show the interacting among the requirements are actors

Use-case diagram

You are hired to develop FAI’s library system with following description

  • (^) Admin who could
    • (^) Manage books, readers (staff, lecturers, and students), etc.
    • (^) Manage borrow/return books
  • (^) Users (staff, lecturers, students) who could
    • (^) View/search books
    • (^) Reserve books
    • (^) Borrow/return books Please draw Use-case diagram for this scenario Activity: Draw use-case diagram
  • (^) 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

  • (^) An algorithm is a step-by-step description of the solution

to a problem

  • (^) An algorithm must be
    • (^) Definite
    • (^) Finite
    • (^) Precise and Effective
    • (^) Implementation independent (only for problem not for programming languages) Developing a solution technique: Algorithm
  • (^) Please list the steps inside an algorithm to find factorial

number of a positive integer

Activity: Find factorial number