No history yet

Structured Problem Solving

From Problem to Plan

Before writing a single line of code, we need a plan. Trying to solve a complex problem by immediately typing into a code editor is like trying to build a house without a blueprint. You might get a wall up, but the structure will be weak and disorganized. The goal is to first translate a human requirement into a set of clear, logical, and unambiguous steps. This is the core of algorithmic thinking.

Two key ideas help us create this blueprint: decomposition and abstraction.

Decomposition is breaking a complex problem down into smaller, more manageable sub-problems.

Abstraction is ignoring the irrelevant details to focus on what's important for the task at hand.

Let's use a real-world example: making a cup of tea. If you were to instruct a robot, you couldn't just say, "Make tea." You would need to decompose the task.

  1. Get a mug.
  2. Get a tea bag.
  3. Put the tea bag in the mug.
  4. Get water.
  5. Heat the water until it boils.
  6. Pour the boiling water into the mug.
  7. Let the tea steep for a few minutes.

Each step is a smaller, simpler instruction. Now, consider abstraction. We don't need to specify how the water is heated. Whether it's in a kettle, on a stove, or in a microwave is an implementation detail. By abstracting that detail away, our core instructions—'heat the water'—remain valid regardless of the tool used. This separation of what to do from how to do it is crucial for clear problem-solving.

Modeling the Logic Flow

Once we've broken down a problem, we need to organize the steps. A simple but powerful way to do this is with an Input-Process-Output (IPO) model. This model forces us to think clearly about what we have, what we need to do, and what we want to get.

ComponentDescriptionTea Example
InputWhat you need to start the process.Mug, tea bag, water
ProcessThe actions taken on the inputs.Heating water, pouring, steeping
OutputThe final result.A cup of hot tea

This structured approach ensures we haven't missed anything. It defines the boundaries of our problem. We know exactly what information we're working with and what our goal is. Every well-defined computational task can be described this way.

Writing the Blueprint

With our logic mapped out, we can write a more formal plan. We have two primary tools for this: pseudocode and flowcharts.

Pseudocode is a simplified, human-readable description of an algorithm. It's not a real programming language, so it doesn't have strict syntax rules. Instead, it uses plain language to describe the logical steps. It’s the middle ground between a simple to-do list and actual code. It must be —given the same input, it must always produce the same output by following the same steps.

// Pseudocode for making tea

START
  GET mug, tea_bag, water

  IF water is not hot THEN
    HEAT water to boiling
  END IF

  PLACE tea_bag in mug
  POUR boiling water into mug
  WAIT 3 minutes

  OUTPUT cup_of_tea
END

A flowchart is a visual representation of the same logic. It uses standard symbols to show the sequence of operations and decisions in an algorithm. This can be especially helpful for understanding complex branching or looping logic at a glance.

Whether you use pseudocode, a flowchart, or just a detailed list, the goal is the same: to create a complete and logical plan before you start coding. This structured approach to problem-solving separates the 'what' from the 'how' and is the foundation for writing clean, effective, and maintainable software.

Quiz Questions 1/6

The process of breaking down a large, complex problem into smaller, more manageable parts is known as what?

Quiz Questions 2/6

In algorithmic thinking, what is the primary goal of abstraction?