0% found this document useful (0 votes)
33 views6 pages

Problem-Solving Process: Computer As A Model of Computation

Module 1

Uploaded by

lisaandrias5
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)
33 views6 pages

Problem-Solving Process: Computer As A Model of Computation

Module 1

Uploaded by

lisaandrias5
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/ 6

THE PROBLEM-SOLVING PROCESS

The problem-solving process using a computer involves a structured approach where the
computer acts as a model of computation to solve a problem efficiently. This process breaks
down complex problems into simpler steps that a computer can execute. Let's explore the
problem-solving process with a focus on how the computer is used as a model of
computation.

In any field of study, problem-solving is a fundamental skill, and in computer science, this
skill is applied using computers. Whether the problem arises from the real world or an
abstract concept, a systematic approach is essential for finding solutions. Since computers are
our tools for problem-solving, it's crucial to understand how they process information.
Typically, a computer with a CPU (Central Processing Unit) follows a model where it takes
input, processes it, and then produces output. This basic model can be expanded to multiple
CPUs in modern computers, but the core principles of input, processing, and output remain
the same. Understanding this model is the first step toward effectively using computers to
solve problems.

Computer as a Model of Computation

In problem-solving, we apply the model of computation where we start with some input
information, process it, and produce the desired output as the solution. While this basic model
works well for simple problems, more complex problems often require multiple iterations of
the input/process/output stages. These iterations produce intermediate results that help solve
parts of the problem before reaching the final solution.

Dr.Remya Chandran, Vimal Jyothi Engineering College (Autonomous) Page 1


The essence of problem-solving lies in how we handle the "process" part of this model. Therefore,
understanding and mastering this stage is crucial.

To illustrate how this model works, consider a straightforward example:


Example: Calculate the average grade for all students in a class.
Input: Collect all the grades, either by typing them in via the keyboard or by reading them
from a storage device like a USB flash drive.
Process: Sum all the grades and calculate the average.
Output: Display the average grade on a monitor, print it, or save it back to a storage device.

This simple example shows how the problem can be solved by following the input, process,
and output steps.

Why the Computer as a Model of Computation?

The computer is used in this process because it can:

 Execute algorithms quickly and efficiently.


Dr.Remya Chandran, Vimal Jyothi Engineering College (Autonomous) Page 2
 Perform repetitive calculations without error (e.g., summing numbers).
 Store and manipulate data in memory.
 Follow logical decisions like branching (if-else) and looping (for, while) as part of an
algorithm.

Steps in the Problem-Solving Process (with the Computer as a Model of


Computation)

1. Understanding the Problem


2. Formulating a Model
3. Developing an Algorithm
4. Writing the Program
5. Testing the Program
6. Evaluating the Solution

1. Understanding the Problem

The first step is to clearly understand what the problem is asking. This means identifying the
data provided, understanding what it represents, and knowing the expected output.

Key Questions to Consider:

 Input Data: What data is available, and in what format?


 Missing Information: Is any data missing? How should it be handled?
 Output Requirements: What needs to be produced, and in what format?
 Processing: What operations need to be performed on the data?

EXAMPLE: Find the area of rectangle

Here, the problem is simple:

 What do we need to find? The area of a rectangle.


 What inputs are needed? The length and width of the rectangle.
 What is the relationship? The area of a rectangle is calculated by multiplying its
length and width.

 Input: Length = 5 units, Width = 4 units.


 Output: Area = Length × Width = 20 square units.

2. Formulating a Model

Dr.Remya Chandran, Vimal Jyothi Engineering College (Autonomous) Page 3


Once the problem is understood, we create a mathematical or logical model to describe the
solution. In this case, the formula for the area of a rectangle is:

Area=Length × Width

This formula represents the model we will use to solve the problem.

3. Developing an Algorithm

An algorithm is a step-by-step procedure to solve the problem. Here’s an algorithm to


calculate the area of a rectangle:

1. Start
2. Input the length of the rectangle.
3. Input the width of the rectangle.
4. Multiply the length by the width to get the area.
5. Output the area.
6. End

Two commonly used representations for an algorithm is by using (1) pseudo code, or (2)
flowcharts.

Pseudocode

Pseudocode is a structured way of writing an algorithm that resembles programming languages but
doesn't follow any specific syntax rules. It helps bridge the gap between the algorithm and actual
code. It's more formal than the plain algorithm and can easily be translated into code, but it avoids
specific language syntax.

Eg: Pseudocode to calculate the area of a rectangle

1. Start

2. Input the length of the rectangle

3. Input the width of the rectangle

4. Area = length * width

5. Output the area

Dr.Remya Chandran, Vimal Jyothi Engineering College (Autonomous) Page 4


6. End

Flochart

A flowchart is a diagram that visually represents a process or a sequence of steps involved in solving
a problem. Each step in the process is depicted by different shapes (like ovals, rectangles, and
diamonds) and is connected by arrows that show the flow of the process.

4. Writing the Program

Steps to Writing a Program


1. Understand the Algorithm:
 Ensure that you have a clear and precise algorithm outlining the steps to solve the
problem.
 The algorithm should include all necessary inputs, operations, and outputs.
2. Translate Algorithm to Pseudocode:
 Before coding, convert the algorithm into pseudocode, which is a simplified, human-
readable representation of the steps.
 Pseudocode helps in visualizing the logic without worrying about syntax.
3. Implement in Code:
o Translate the pseudocode into a specific programming language. This involves:
 Defining Variables: Initialize variables as needed.
 Input Handling: Write code to capture user inputs or read data.
 Processing Logic: Implement the core algorithm steps in code.
 Output Handling: Display or return results to the user.
4. Testing and Debugging:
 After writing the code, test it with various inputs to ensure it works as expected.
 Debug any issues or errors that arise during testing.

Dr.Remya Chandran, Vimal Jyothi Engineering College (Autonomous) Page 5


Next, we translate the algorithm into code. Here's a simple Python program for the problem.

# Input the length and width


length = float(input("Enter the length of the rectangle: "))
width = float(input("Enter the width of the rectangle: "))

# Calculate the area


area = length * width

# Output the area


print("The area of the rectangle is:", area)

5. Testing the Program

Once the program is written, it needs to be tested with various inputs to ensure it works
correctly.

Example:

 Test case 1:
o Input: Length = 5, Width = 4
o Output: The area of the rectangle is: 20
 Test case 2:
o Input: Length = 7, Width = 3
o Output: The area of the rectangle is: 21

6. Evaluating the Solution

Finally, after testing, evaluate whether the solution is correct and efficient. Ask:

 Does the program correctly compute the area for all inputs?
 Are there any cases where it might fail (e.g., negative inputs)?
 Could it be improved in any way?

For example, we could add a check to ensure that the length and width are positive values.

if length > 0 and width > 0:


area = length * width
print("The area of the rectangle is:", area)
else:
print("Length and width must be positive values.")

Dr.Remya Chandran, Vimal Jyothi Engineering College (Autonomous) Page 6

You might also like