Problem and Computer Programming Problem

1. What is a Problem?

A problem is a situation in which we have:

  • something that needs to be achieved,
  • some difficulty or challenge,
  • and we need to find a suitable solution.

Simple example

Suppose you want to travel from Kochi to Thiruvananthapuram.

The problem is:

How can I reach Thiruvananthapuram from Kochi efficiently?

There may be several possible solutions:

  • Bus
  • Train
  • Car
  • Flight

Now you need to consider factors such as:

  • time,
  • cost,
  • distance,
  • convenience.

So, a problem is not simply a question. It is a situation requiring a decision or solution.


2. What is a Computer Programming Problem?

A computer programming problem is a problem that can be solved, fully or partially, by developing an algorithm and implementing it as a computer program.

In simple words:

A programming problem tells us what information is given, what result is required, and what conditions the solution must satisfy.

For example:

Given a list of numbers, find the largest number.

A computer can solve this problem by following a sequence of instructions.


3. Four Important Parts of a Programming Problem

A programming problem can usually be understood using four questions:

① What is given? → Input

The input is the information given to the program.

Example:

10 25 7 42 18

② What is required? → Output

The output is the result that the program should produce.

For the above input:

42

because 42 is the largest number.


③ What limitations exist? → Constraints

Constraints tell us the boundaries within which our solution must work.

For example:

The list can contain up to 1,000,000 numbers.

This is important because an algorithm that works well for 100 numbers may not be suitable for 1 million numbers.

Other constraints can involve:

  • execution time,
  • memory,
  • input size,
  • allowed values,
  • required output format.

④ What are we trying to achieve? → Objective

The objective tells us exactly what the program is expected to accomplish.

For example:

Find the largest number in the given list.


4. From Problem to Program

Students should understand this flow:

Real-world Problem
        ↓
Define the Programming Problem
        ↓
Identify Input
        ↓
Identify Output
        ↓
Identify Constraints
        ↓
Design Algorithm
        ↓
Write Program
        ↓
Test the Solution

This is an important part of algorithmic thinking.


5. Example: Finding the Largest Number

Consider the problem:

Given N integers, find the largest integer.

Problem

Find the largest number.

Input

5
23 15 42 8 16

Here:

N = 5
Numbers = 23, 15, 42, 8, 16

Output

42

Constraint

Suppose:

1 ≤ N ≤ 1,000,000

Algorithm

We can scan the numbers one by one.

largest = first number

for each remaining number:
    if number > largest:
        largest = number

output largest

Notice that the algorithm is the solution strategy, while the program is the implementation of that strategy.


6. A Very Simple Way to Remember

I would give students this four-question framework:

Question    Programming concept
What do I have?    Input
What do I need?    Output
What limitations do I have?    Constraints
What exactly must I accomplish?    Objective

Then:

How will I accomplish it? → Algorithm

and finally:

How will I implement it? → Program


One-line definition for students

Problem

A problem is a situation or challenge for which we need to find a solution.

Computer Programming Problem

A computer programming problem is a clearly defined task in which a computer must transform given input into the required output using an appropriate algorithm, while satisfying specified constraints.

The key idea

Problem → Input + Output + Constraints + Objective → Algorithm → Program

This distinction is particularly important in algorithmic thinking because we should understand and define the problem before trying to write code.

Comments

Popular posts from this blog

Algorithmic Thinking with Python UCEST 105- KTU First Semester BTech Course 2024 scheme notes pdf - Dr Binu V P 9847390760

Lab Experiments and Solutions - Algorithmic thinking with Python KTU S1 2024 scheme

PadLocking