GE 3151 - PROBLEM SOLVING & PYTHON
PROGRAMMING
UNIT I COMPUTATIONAL THINKING AND PROBLEM SOLVING
Topic: 1.2. Identification of Computational Problems
What Is Computer Science?
• It is fundamentally about computational
problem solving
• i.e., solving problems by the use of computation.
What is computation?
• It is any type of calculation that includes both
arithmetical and non-arithmetical steps and
follows a well-defined model
• E.g.: Algorithm.
Types of Computational Problems
 Decision Problems
 Search Problems
 Counting Problems
 Optimization Problems
 Function Problems
5
Decision Problems
A decision problem is a problem where the answer is either
"yes" or "no." You are asked to check if something meets certain
conditions, and you only need to decide whether the answer is
yes or no.
Simple Example:
Scenario: You want to know if a movie is shorter than 2 hours.
Steps:
Input: The length of the movie.
Criteria: Is the movie less than 2 hours?
Output: Yes (if it's shorter) or No (if it's not).
Everyday Analogy:
Before leaving home, you check if you have your phone.
The answer is simple: either you have it ("yes") or you don't ("no").
This is a decision problem because it only needs a yes/no answer.
Search Problems
6
A search problem involves finding a solution from a set of
possible options. The goal is to identify an element (or
elements) that meet certain criteria from a large collection.
Search problems are common in computer science, where
algorithms are designed to efficiently locate information within
a structured dataset (like a list or graph).
Key Characteristics of a Search Problem:
Input: A collection of elements (e.g., a list, array, graph).
Criteria: The conditions that the element(s) must satisfy.
Output: The element(s) that meet the criteria.
7
Search problem-Example
Scenario:
You have a list of 1000 employees and need to find the person
who has the highest salary. This is a search problem where you are
searching for an employee based on a specific criterion: the highest
salary.
Steps to Solve:
Input:
A list of employees, each with their salary information.
Criteria:
The employee with the highest salary.
Output:
The employee's name (or other identifying information).
8
Cntd..
Everyday Analogy:
Imagine looking for your car keys in a room
full of items. You know what the keys look
like (the criteria), and you search through
various objects (the input) until you find the
keys (the output). This is essentially a search
problem in a real-world context.
9
Counting Problems
A counting problem is a problem where you need to determine how many
items in a set meet a specific condition. Instead of asking for a "yes" or
"no" answer, like in a decision problem, you're asked to count how many
elements satisfy certain criteria.
Simple Example:
Scenario: You have a bag of 100 candies, and you want to
know how many of them are red.
Steps:
Input: The bag of 100 candies.
Criteria: Candies that are red.
Output: The total number of red candies.
10
Cntd..
• Everyday Analogy:
Imagine counting how many days in a month are
sunny. You check each day and count how many
were sunny. This is a counting problem because
you're determining how many days meet the
condition (sunny days).
11
Optimization Problems
An optimization problem is a problem where you need to find the
best solution from a set of possible options. The goal is to maximize or
minimize a certain value, such as cost, time, distance, or efficiency,
based on certain criteria.
Simple Example:
Scenario: You are planning a road trip and want to find the
shortest route between two cities.
Steps:
Input: All possible routes between the cities.
Criteria: Minimize the distance (shortest route).
Output: The shortest route.
12
Everyday Analogy:
Imagine you're shopping and want to buy a
laptop. You have a budget and want the
best laptop you can get for the lowest
price. This is an optimization problem because
you're trying to maximize the quality of the
laptop while minimizing the cost.
13
Function Problem
• A functional problem is a problem where you
need to calculate or find a specific value based
on given information. The goal is to produce
an exact result rather than just a "yes" or "no"
answer.
14
Cntd..
Simple Example:
Scenario: You want to know how long it will take to drive 200 kilometers
at a speed of 50 kilometers per hour.
Steps:
Input: Distance (200 km) and speed (50 km/h).
Criteria: Use the formula: Time = Distance / Speed.
Output: The time it will take (in this case, 4 hours).
Everyday Analogy:
You have 5 apples, and each costs $2. You want to know the total cost. The answer
is $10, calculated by multiplying the price ($2) by the number of apples (5). This
is a functional problem because you're calculating a specific value based on the
inputs.
Computational thinking can be split into four parts,
 Decomposition
 Pattern recognition
 Abstraction
 Algorithmic design
• In order to solve a problem computationally, two things are
needed,
 A representation that captures all the relevant aspects of the problem
 An algorithm that solves the problem by use of the representation
Parts of computational thinking
16
Cntd..
Problem: Create an app that calculates the average grade for each
student.
1. Decomposition:
We need to break the problem down into smaller tasks.
Input collection: Gather the grades for each
assignment for every student.
Grade calculation: Calculate the average grade for
each student.
Display result: Output the average grade for each
student.
Now the problem is divided into manageable chunks.
17
Cntd..
2. Pattern Recognition:
Identify patterns and repetitive elements in the
problem.
• The steps to compute the average for one
student can be repeated for all students.
• We can recognize that the calculation of an
average involves a common formula (sum of
grades divided by the number of grades).
18
Cntd..
3. Abstraction:
Generalize the problem to focus only on the important
details.
Ignore unnecessary details like the subject of
assignments or individual student names.
Abstract the process:
We just need to know the grades for each student and apply
the same calculation for all students.
Focus on the structure: We will have a list of numbers (grades) for
each student, and the task is to calculate the average for that list.
19
Cntd..
4. Algorithm Design:
• Create a step-by-step plan (algorithm) to solve the problem.
Step-by-step algorithm:
Input: Collect the grades for each student (e.g., in a
list or table).
Process:
For each student:
• Sum all the grades.
• Divide the sum by the number of assignments to find the average.
Output: Display the average grade for each
student.
• Computational thinking allows us,
To take a complex problem
Understand what the problem is
Develop possible solutions
 Present these solutions in a way that a computer,
a human, or both, can understand.

Unit I -1.2. Identification of Computational Problems (2).pptx

  • 1.
    GE 3151 -PROBLEM SOLVING & PYTHON PROGRAMMING UNIT I COMPUTATIONAL THINKING AND PROBLEM SOLVING Topic: 1.2. Identification of Computational Problems
  • 2.
    What Is ComputerScience? • It is fundamentally about computational problem solving • i.e., solving problems by the use of computation.
  • 3.
    What is computation? •It is any type of calculation that includes both arithmetical and non-arithmetical steps and follows a well-defined model • E.g.: Algorithm.
  • 4.
    Types of ComputationalProblems  Decision Problems  Search Problems  Counting Problems  Optimization Problems  Function Problems
  • 5.
    5 Decision Problems A decisionproblem is a problem where the answer is either "yes" or "no." You are asked to check if something meets certain conditions, and you only need to decide whether the answer is yes or no. Simple Example: Scenario: You want to know if a movie is shorter than 2 hours. Steps: Input: The length of the movie. Criteria: Is the movie less than 2 hours? Output: Yes (if it's shorter) or No (if it's not). Everyday Analogy: Before leaving home, you check if you have your phone. The answer is simple: either you have it ("yes") or you don't ("no"). This is a decision problem because it only needs a yes/no answer.
  • 6.
    Search Problems 6 A searchproblem involves finding a solution from a set of possible options. The goal is to identify an element (or elements) that meet certain criteria from a large collection. Search problems are common in computer science, where algorithms are designed to efficiently locate information within a structured dataset (like a list or graph). Key Characteristics of a Search Problem: Input: A collection of elements (e.g., a list, array, graph). Criteria: The conditions that the element(s) must satisfy. Output: The element(s) that meet the criteria.
  • 7.
    7 Search problem-Example Scenario: You havea list of 1000 employees and need to find the person who has the highest salary. This is a search problem where you are searching for an employee based on a specific criterion: the highest salary. Steps to Solve: Input: A list of employees, each with their salary information. Criteria: The employee with the highest salary. Output: The employee's name (or other identifying information).
  • 8.
    8 Cntd.. Everyday Analogy: Imagine lookingfor your car keys in a room full of items. You know what the keys look like (the criteria), and you search through various objects (the input) until you find the keys (the output). This is essentially a search problem in a real-world context.
  • 9.
    9 Counting Problems A countingproblem is a problem where you need to determine how many items in a set meet a specific condition. Instead of asking for a "yes" or "no" answer, like in a decision problem, you're asked to count how many elements satisfy certain criteria. Simple Example: Scenario: You have a bag of 100 candies, and you want to know how many of them are red. Steps: Input: The bag of 100 candies. Criteria: Candies that are red. Output: The total number of red candies.
  • 10.
    10 Cntd.. • Everyday Analogy: Imaginecounting how many days in a month are sunny. You check each day and count how many were sunny. This is a counting problem because you're determining how many days meet the condition (sunny days).
  • 11.
    11 Optimization Problems An optimizationproblem is a problem where you need to find the best solution from a set of possible options. The goal is to maximize or minimize a certain value, such as cost, time, distance, or efficiency, based on certain criteria. Simple Example: Scenario: You are planning a road trip and want to find the shortest route between two cities. Steps: Input: All possible routes between the cities. Criteria: Minimize the distance (shortest route). Output: The shortest route.
  • 12.
    12 Everyday Analogy: Imagine you'reshopping and want to buy a laptop. You have a budget and want the best laptop you can get for the lowest price. This is an optimization problem because you're trying to maximize the quality of the laptop while minimizing the cost.
  • 13.
    13 Function Problem • Afunctional problem is a problem where you need to calculate or find a specific value based on given information. The goal is to produce an exact result rather than just a "yes" or "no" answer.
  • 14.
    14 Cntd.. Simple Example: Scenario: Youwant to know how long it will take to drive 200 kilometers at a speed of 50 kilometers per hour. Steps: Input: Distance (200 km) and speed (50 km/h). Criteria: Use the formula: Time = Distance / Speed. Output: The time it will take (in this case, 4 hours). Everyday Analogy: You have 5 apples, and each costs $2. You want to know the total cost. The answer is $10, calculated by multiplying the price ($2) by the number of apples (5). This is a functional problem because you're calculating a specific value based on the inputs.
  • 15.
    Computational thinking canbe split into four parts,  Decomposition  Pattern recognition  Abstraction  Algorithmic design • In order to solve a problem computationally, two things are needed,  A representation that captures all the relevant aspects of the problem  An algorithm that solves the problem by use of the representation Parts of computational thinking
  • 16.
    16 Cntd.. Problem: Create anapp that calculates the average grade for each student. 1. Decomposition: We need to break the problem down into smaller tasks. Input collection: Gather the grades for each assignment for every student. Grade calculation: Calculate the average grade for each student. Display result: Output the average grade for each student. Now the problem is divided into manageable chunks.
  • 17.
    17 Cntd.. 2. Pattern Recognition: Identifypatterns and repetitive elements in the problem. • The steps to compute the average for one student can be repeated for all students. • We can recognize that the calculation of an average involves a common formula (sum of grades divided by the number of grades).
  • 18.
    18 Cntd.. 3. Abstraction: Generalize theproblem to focus only on the important details. Ignore unnecessary details like the subject of assignments or individual student names. Abstract the process: We just need to know the grades for each student and apply the same calculation for all students. Focus on the structure: We will have a list of numbers (grades) for each student, and the task is to calculate the average for that list.
  • 19.
    19 Cntd.. 4. Algorithm Design: •Create a step-by-step plan (algorithm) to solve the problem. Step-by-step algorithm: Input: Collect the grades for each student (e.g., in a list or table). Process: For each student: • Sum all the grades. • Divide the sum by the number of assignments to find the average. Output: Display the average grade for each student.
  • 20.
    • Computational thinkingallows us, To take a complex problem Understand what the problem is Develop possible solutions  Present these solutions in a way that a computer, a human, or both, can understand.