Problem-Formulation and Analysis

Master computational thinking and problem-solving strategies

Learning Navigation

Introduction
Define Problem
Analyze Problem
Decomposition
Pattern Recognition
User Interface
Quiz
Flashcards

Introduction to Problem-Solving

Programming

Programs in Daily Life

Computer programs are everywhere in our daily lives - from mobile apps and websites to smart home devices and artificial intelligence systems. Understanding how to formulate and analyze problems is the foundation of creating effective solutions through programming.

The Importance of Computational Thinking

Computational thinking is a problem-solving approach that involves breaking down complex problems into manageable parts. It helps us think logically and systematically about problems before writing any code. This skill is valuable not just in programming, but in many aspects of life and work.

  • Identify and define problems clearly
  • Analyze problems systematically
  • Break down complex problems into smaller sub-problems
  • Recognize patterns and similarities across problems
  • Design effective user interfaces and solutions

1.1 Define a Problem

Before solving any problem, we must first define it clearly. Problem definition involves understanding what needs to be solved, who is affected, and what the desired outcome is. Two powerful tools for problem definition are the 5W1H method and mind mapping.

The 5W1H Method

The 5W1H method helps us ask the right questions to fully understand a problem:

  • What - What is the problem? What needs to be achieved?
  • Who - Who is affected? Who will use the solution?
  • When - When does the problem occur? When is the solution needed?
  • Where - Where does the problem happen? Where will the solution be used?
  • Why - Why is this problem important? Why does it need to be solved?
  • How - How will we approach the solution? How will we measure success?
Example 1.1: Coffee Shop Online Service

A coffee shop wants to provide online ordering services. Using 5W1H:

  • What: Online ordering system for coffee and snacks
  • Who: Regular customers and new customers
  • When: During business hours, with advance ordering option
  • Where: Mobile app and website, pickup at store
  • Why: Reduce waiting time, increase convenience, expand customer base
  • How: Develop user-friendly interface, integrate payment system, implement order tracking

Mind Mapping

Mind maps are visual tools that help organize thoughts and ideas around a central problem. They allow us to see connections between different aspects of a problem and brainstorm potential solutions. Start with the main problem in the center and branch out to related concepts, requirements, and constraints.

1.2 Analyse a Problem

Problem analysis involves understanding the inputs needed, the processes required, and the outputs expected. This is known as the IPO (Input-Process-Output) cycle, which is fundamental to all computer programs.

The IPO Cycle

Data Analysis
  • Input: Data or information that the program receives
  • Process: Operations performed on the input data
  • Output: Results produced by the program
Example: BMI Calculator

A Body Mass Index (BMI) calculator demonstrates the IPO cycle clearly:

Input Process Output
Weight (kg) Calculate BMI using formula BMI value
Height (m) Compare with standard ranges Health category

BMI Formula:

$$BMI = \frac{weight}{height^2}$$
Example: Mortgage Calculator
Input Process Output
Loan amount Calculate monthly payment Monthly payment amount
Interest rate Calculate total interest Total interest paid
Loan period Generate payment schedule Payment schedule

1.3 Decompose a Problem

Decomposition is the process of breaking down a complex problem into smaller, more manageable sub-problems. This makes it easier to understand, solve, and test each part independently before combining them into a complete solution.

Top-Down Approach

The top-down approach starts with the overall problem and breaks it down into smaller sub-problems. Each sub-problem can be further divided until we reach problems simple enough to solve directly. This is also known as divide-and-conquer.

Example: Making Breakfast

Main Problem: Make breakfast

  • Sub-problem 1: Prepare toast
    • Get bread from pantry
    • Put bread in toaster
    • Wait for toasting
    • Apply butter
  • Sub-problem 2: Prepare eggs
    • Get eggs from refrigerator
    • Heat pan
    • Crack eggs into pan
    • Cook until done
  • Sub-problem 3: Prepare drink
    • Boil water
    • Add coffee/tea
    • Add milk/sugar if desired

Stepwise Refinement

Stepwise refinement is the process of gradually adding more detail to each sub-problem until we have a complete, detailed solution. We start with a high-level description and progressively refine it with more specific steps.

Example: Calculate Trapezium Area

Trapezium Area Formula:

$$A = \frac{(a+b) \times h}{2}$$

where a and b are the parallel sides, h is the height

Decomposition:

  1. Input: Get values for a, b, and h
  2. Process: Calculate sum of parallel sides (a + b)
  3. Process: Multiply sum by height
  4. Process: Divide result by 2
  5. Output: Display the area

Modularised Design

Modularised design means organizing a program into separate modules or functions, each responsible for a specific task. This makes the code easier to understand, test, debug, and reuse. Each module should have a clear purpose and well-defined inputs and outputs.

1.4 Identify Common Elements Across Similar Problems

Pattern recognition is the ability to identify similarities and common elements across different problems. When we recognize patterns, we can apply solutions from one problem to similar problems, making problem-solving more efficient.

Patterns

Bottom-Up Approach

The bottom-up approach starts by looking at specific examples and identifying common patterns. We then generalize these patterns to create a solution that works for a broader range of problems.

Example: Making Instant Drinks

Consider making different instant drinks (coffee, tea, hot chocolate):

Common Pattern:

  1. Boil water
  2. Put instant powder/bag in cup
  3. Pour hot water into cup
  4. Stir (if needed)
  5. Add milk/sugar (optional)

By recognizing this pattern, we can create a general procedure for making any instant drink, rather than writing separate instructions for each type.

Example: Sorting Data

Whether we're sorting students by height, weight, age, or test scores, the pattern is the same:

  1. Compare two items
  2. Swap if out of order
  3. Repeat until sorted

This is the fundamental pattern of sorting algorithms, which can be applied to any comparable data.

Computational Thinking

According to computer scientist Jeannette M. Wing, computational thinking involves four key aspects:

  • Decomposition: Breaking down complex problems into manageable parts
  • Pattern Recognition: Identifying similarities and common elements
  • Abstraction: Focusing on important information while ignoring irrelevant details
  • Algorithm Design: Creating step-by-step solutions that can be implemented

1.5 Designing User Interface and Components

A well-designed user interface (UI) is crucial for making programs usable and accessible. The UI is how users interact with your program, so it should be intuitive, clear, and efficient.

UI Design

Wireframes

Wireframes are simple sketches or diagrams that show the layout and structure of a user interface before it's built. They help us plan where different elements will be placed and how users will navigate through the program.

Example: BMI Calculator Wireframe

A BMI calculator interface might include:

  • Title: "BMI Calculator"
  • Input field: Weight (with unit label)
  • Input field: Height (with unit label)
  • Button: "Calculate"
  • Display area: BMI result
  • Display area: Health category

UI Components

Common UI components include:

  • Text fields: For user input
  • Buttons: For triggering actions
  • Labels: For displaying text and instructions
  • Dropdown menus: For selecting from options
  • Checkboxes: For multiple selections
  • Radio buttons: For single selection from options

Design Principles

  • Clarity: Make it obvious what each element does
  • Consistency: Use similar design patterns throughout
  • Feedback: Provide immediate response to user actions
  • Simplicity: Don't overwhelm users with too many options
  • Accessibility: Ensure the interface works for all users

Interactive Quiz

Question 1
What does the "5W1H" method help us to do?
  • A) Write code faster
  • B) Define and understand a problem clearly
  • C) Debug programs
  • D) Design user interfaces
Question 2
What does IPO stand for in problem analysis?
  • A) Internet Protocol Operations
  • B) Input-Process-Output
  • C) Information Processing Order
  • D) Integrated Program Organization
Question 3
Which approach starts with the overall problem and breaks it into smaller parts?
  • A) Bottom-up approach
  • B) Top-down approach
  • C) Side-to-side approach
  • D) Random approach
Question 4
What is decomposition in problem-solving?
  • A) Combining multiple problems into one
  • B) Breaking down complex problems into smaller sub-problems
  • C) Ignoring parts of the problem
  • D) Making problems more complex
Question 5
Pattern recognition helps us to:
  • A) Identify similarities across different problems
  • B) Make problems more difficult
  • C) Avoid solving problems
  • D) Write longer code
Question 6
In the BMI calculator example, weight and height are:
  • A) Outputs
  • B) Processes
  • C) Inputs
  • D) Algorithms
Question 7
What is stepwise refinement?
  • A) Making code run faster
  • B) Gradually adding more detail to each sub-problem
  • C) Removing unnecessary code
  • D) Testing programs
Question 8
According to Jeannette M. Wing, computational thinking includes which four aspects?
  • A) Decomposition, Pattern Recognition, Abstraction, Algorithm Design
  • B) Input, Process, Output, Storage
  • C) Planning, Coding, Testing, Debugging
  • D) What, Who, When, Where
Question 9
What is the purpose of a wireframe in UI design?
  • A) To write the final code
  • B) To plan the layout and structure before building
  • C) To test the program
  • D) To add colors and images
Question 10
Modularised design means:
  • A) Writing all code in one long file
  • B) Organizing code into separate modules or functions
  • C) Using only one programming language
  • D) Avoiding functions completely
Question 11
Which of the following is NOT one of the 5W1H questions?
  • A) What
  • B) Why
  • C) Which
  • D) How
Question 12
The bottom-up approach in pattern recognition starts with:
  • A) The overall problem
  • B) Specific examples and identifying patterns
  • C) The user interface
  • D) Writing code immediately
Question 13
What is abstraction in computational thinking?
  • A) Making problems more complex
  • B) Focusing on important information while ignoring irrelevant details
  • C) Writing abstract art
  • D) Avoiding problem-solving
Question 14
In UI design, which principle ensures the interface works for all users?
  • A) Simplicity
  • B) Consistency
  • C) Accessibility
  • D) Feedback
Question 15
Algorithm design in computational thinking involves:
  • A) Creating step-by-step solutions
  • B) Ignoring the problem
  • C) Making random guesses
  • D) Only using one solution method

Interactive Flashcards

Click on any card to flip and reveal the definition

Decomposition
Breaking down complex problems into smaller, manageable sub-problems
Sub-problem
A smaller part of a larger problem that can be solved independently
Module
A self-contained unit of code that performs a specific function
Top-down approach
Starting with the overall problem and breaking it into smaller parts
Bottom-up approach
Starting with specific examples and identifying common patterns
Divide-and-conquer
A strategy of breaking problems into parts and solving each separately
IPO cycle
Input-Process-Output: the fundamental cycle of all computer programs
Pattern recognition
Identifying similarities and common elements across different problems
Stepwise refinement
Gradually adding more detail to sub-problems until complete
Computational thinking
A problem-solving approach using decomposition, patterns, abstraction, and algorithms
Abstraction
Focusing on important information while ignoring irrelevant details
Algorithm design
Creating step-by-step solutions that can be implemented
Wireframe
A simple sketch showing the layout and structure of a user interface
5W1H method
A problem definition tool using What, Who, When, Where, Why, and How
Mind map
A visual tool for organizing thoughts and ideas around a central problem
Input
Data or information that a program receives
Process
Operations performed on input data to produce output
Output
Results produced by a program after processing input
User Interface (UI)
How users interact with a program or system
Modularised design
Organizing programs into separate modules, each with a specific purpose
Problem definition
Clearly understanding what needs to be solved and the desired outcome
Problem analysis
Understanding inputs, processes, and outputs required for a solution
UI components
Elements like buttons, text fields, and labels that make up an interface
Accessibility
Ensuring interfaces work for all users, including those with disabilities
Problem scope
The boundaries and limitations of what a solution will address
Reusability
The ability to use code or modules in multiple programs
made with

Trust & Safety

Report this page