Problem Solving

Problem Solving

February 10, 2021 7 min read 4 views 0 discussions
Table of Contents

    Problem-solving skills are recognized as an integral component of computer programming. It is a demand and intricate process which is equally important throughout the project life cycle especially – study, designing, development, testing, and implementation stages. The computer problem-solving process requires:

    • Problem anticipation
    • Careful planning
    • Proper thought process
    • Logical precision
    • Problem analysis
    • Persistence and attention.
    A computer is a very powerful tool for solving problems. It is a symbol-manipulating machine that follows a set of stored instructions called a program. It performs these manipulations very quickly and has memory for storing input, lists of commands, and output. A computer cannot think in the way we associate with humans. When using the computer to solve a problem, you must specify the needed initial data, the operations which need to be performed (in order of performance), and what results in you want for output. If any of these instructions are missing, you will get either no results or invalid results. In either case, your problem has not yet been solved. Therefore, several steps need to be considered before writing a program. These steps may free you from hours of finding and removing errors in your program (a process called debugging).

      Problem Solving Techniques

      Problem-solving is a creative process that defines systematization and mechanization. There are a number of steps that can be taken to raise the level of one’s performance in problem-solving.

       

      Steps for Problem – Solving

      A problem-solving technique follows certain steps in finding the solution to a problem. Let us look into the steps one by one:

      Problem definition phase

      In the problem definition phase, we must emphasize what must be done rather than how is it to be done.

       

      Getting started on a problem

      There are many ways of solving a problem and there may be several solutions. So, it is difficult to recognize immediately which path could be more productive. Sometimes you do not have any idea where to begin solving a problem, even if the problem has been defined. Such block sometimes occurs because you are overly concerned with the details of the implementation even before you have completely understood or worked out a solution. The best advice is not to get concerned with the details. Those can come later when the intricacies of the problem have been understood.

      The use of specific examples

      To get started on a problem, we can make use of heuristics i.e., the rule of thumb. This approach will allow us to start on the problem by picking a specific problem we wish to solve and try to work out the mechanism that will allow solving this particular problem. It is usually much easier to work out the details of a solution to a specific problem because the relationship between the mechanism and the problem is more clearly defined. This approach of focusing on a particular problem can give us the foothold we need for making a start on the solution to the general problem.

       

      Similarities among problems

      One way to make a start is by considering a specific example. Another approach is to bring the experience to bear on the current problem. So, it is important to see if there are any similarities between the current problem and the past problems which we have solved. The more experience one has the more tools and techniques one can bring to bear in tackling the given problem. But sometimes, it blocks us from discovering a desirable or better solution to the problem. A skill that is important to try to develop in problem - solving is the ability to view a problem from a variety of angles. One must be able to metaphorically turn a problem upside down, inside out, sideways, backward, forwards, and so on. Once one has developed this skill it should be possible to get started on any problem.

       

      Working backward from the solution

      In some cases, we can assume that we already have the solution to the problem and then try to work backward to the starting point. Even a guess at the solution to the problem may be enough to give us a foothold to start on the problem. We can systematize the investigations and avoid duplicate efforts by writing down the various steps taken and explorations made. Another practice that helps to develop problem-solving skills is, once we have solved a problem, to consciously reflect back on the way we went about discovering the solution.

       

      Using Computer as a Problem - Solving Tool

      1. Develop an Algorithm and a Flowchart.
      2. Write the program in a computer language (for example say C programming language).
      3. Enter the program using some editor.
      4. Test and debug the program.
      5. Run the program, input data, and get the results.

      Algorithm

      An algorithm is a finite set of steps defining the solution of a particular problem. An algorithm is expressed in pseudocode - something resembling C language or Pascal, but with some statements in English rather than within the programming language.

      a set of steps to accomplish or complete a task that is described precisely enough that a computer can run it.

      Criteria to be followed by an Algorithm

      The following is the criteria to be followed by an algorithm:
      • Input: There should be zero or more values that are to be supplied.
      • Output: At least one result is to be produced.
      • Definiteness: Each step must be clear and unambiguous.
      • Finiteness: If we trace the steps of an algorithm, then for all cases, the algorithm must terminate after a finite number of steps.
      • Effectiveness: Each step must be sufficiently basic that a person using only paper and pencil can in principle carry it out. In addition, not only each step is definite, but it must also be feasible.


      Example 1:  Let us try to develop an algorithm to compute and display the sum of two numbers.

      1. Start
      2. Read two numbers a and b
      3. Calculate the sum of a and b and store it in sum
      4. Display the value of the sum
      5. Stop

      Example 2: Let us try to develop an algorithm to compute and print the average of a set of data values.

      1. Start
      2. Set the sum of the data values and the count to zero.
      3. As long as the data values exist, add the next data value to the sum and add 1 to the count.
      4. To compute the average, divide the sum by the count.
      5. Display the average.
      6. Stop

      Example 3: Write an algorithm to calculate the factorial of a given number.

      1. Start
      2. Read the number n
      3. [Initialize] i ← 1 , fact ← 1
      4. Repeat steps 4 through 6 until i = n
      5. fact ← fact * i 6. i ← i + 1 7. Print fact
      6. Stop

      Example 4: Write an algorithm to check that whether the given number is prime or not.

      1. Start
      2. Read the number num
      3. [Initialize] i ← 2 , flag ← 1
      4. Repeat steps 4 through 6 until i < num or flag = 0
      5. rem ← num mod i
      6. if rem = 0 then flag ← 0 else i ← i + 1
      7. if flag = 0 then Print Number is not prime Else Print Number is prime
      8. Stop

      Analysis of algorithm complexity

      Algorithms usually possess the following qualities and capabilities:
      • Easily modifiable if necessary.
      • They are easy, general, and powerful.
      • They are correct for a clearly defined solution.
      • Require less computer time, storage and peripherals i.e. they are more economical.
      • They are documented well enough to be used by others who do not have a detailed knowledge of the inner working.
      • They are not dependable on being run on a particular computer.
      • The solution is pleasing and satisfying to its designer and user.
      • They are able to be used as a sub-procedure for other problems.

      Flowcharts

      What is a flowchart?

      • A flowchart is a picture (graphical representation) of the problem-solving process.
      • A flowchart gives a step-by-step procedure for the solution of a problem.

      Elements of a flowchart

      • Various geometrical shaped boxes represent the steps of the solution.
      • The boxes are connected by directional arrows to show the flow of the solution.

      Uses of a flowchart

      • To specify the method of solving a problem.
      • To plan the sequence of a computer program.
      • Communicate ideas, solutions.

      Drawing a flowchart

      • Identify input and output.
      • Apply reasoning skills to solve the problem.
      • Draw the flowchart using the appropriate symbols and arrows to show the sequence of steps in solving the problem.

      Basic Symbols used in flowchart design

      Community Q&A