Follow us

How to Solve Any Problem with a Computer: Analysis, Algorithms & Flowcharts

inqelio

How to Solve Any Problem with a Computer: Analysis, Algorithms & Flowcharts — The Complete Guide

Solving a problem using a computer is not just about writing code. Before touching a keyboard, a programmer follows a systematic process — computational thinking — that transforms a vague idea into a working solution. The three fundamental steps of problem solving in programming are Problem Analysis, Algorithm Design, and Flowcharting.

Steps of problem solving in programming: analysis, algorithm, flowchart

1. What Is Problem Analysis?

Analysis answers: What exactly must be built? Roughly 60–70% of software failures trace back to poor requirements, not bad coding. This stage is the heart of requirements engineering basics.

Stages of Analysis

StageQuestion it answersOutput
UnderstandingWhat is the problem in plain words?One-sentence problem statement
SpecificationWhat are the inputs, outputs, formulas?Formal input/output contract
DecompositionCan it be broken into subproblems?List of smaller tasks
ConstraintsWhat limits exist (ranges, precision, time)?Documented constraints

The IPO Chart (Input / Process / Output)

A practical analysis tool in programming logic and design. Example — average of exam grades:

InputProcessOutput
Number of students n, then n gradesSum the grades, divide by nAverage = (sum of grades) ÷ n

Edge Cases You Must Hunt For

  • Zero or empty input — if n = 0, the average is undefined (division by zero).
  • Boundary values — grades must satisfy 0 ≤ grade ≤ 100.
  • Invalid input — negative grades, non-numeric data, extremely large numbers.
  • Degenerate cases — one element, all values equal, already-sorted data.

Functional vs. Non-Functional Requirements

TypeDescriptionExample
FunctionalWhat the program computes"Convert Fahrenheit to Celsius"
Non-functionalHow well it must do it"Respond within 1 second; handle 10,000 records"

Classic example: given Fahrenheit (input), produce Celsius (output):

C = (5/9) × (F − 32)

2. How to Design an Algorithm

An algorithm is a finite, unambiguous, effective sequence of steps — the core skill of algorithm design for beginners. The Böhm–Jacopini theorem (1966) proves any algorithm can be written with only three control structures in programming:

StructurePurposePseudocode pattern
SequenceSteps in orderstep1; step2
SelectionChoosing between pathsIF condition THEN ... ELSE ...
IterationRepeating stepsWHILE condition DO ...

Top-Down Decomposition (Divide and Conquer)

Divide and conquer problem solving breaks a complex problem into subproblems. Example — computing a student's final result:

  1. ReadData (name, marks in 3 subjects)
  2. ComputeAverage (sum ÷ 3)
  3. DetermineGrade (average → A/B/C/D/F)
  4. DisplayResult (name, average, grade)

Stepwise Refinement: Finding the Largest Number

How to write pseudocode: refine a vague idea into precise steps. "Find the largest number in a list" becomes:

START
  READ n
  READ max ← first number
  SET i ← 2
  WHILE i ≤ n DO
    READ num
    IF num > max THEN
      max ← num
    ENDIF
    i ← i + 1
  ENDWHILE
  PRINT max
END

Trace Table (Desk Checking)

Trace table desk checking verifies the algorithm before coding. Input: 5, 3, 9, 2:

Iterationnumnum > max?max after
Initial3—3
19Yes9
22No9

Expected output: 9 ✓

Algorithm Quality Criteria

CriterionQuestion
CorrectnessRight output for ALL valid inputs?
EfficiencyHow do time and memory grow with input size?
SimplicityCan another person read and understand it?
GeneralityDoes it handle the whole input range?

A First Look at Efficiency (Big-O Notation Explained Simply)

Checking a list for duplicates: a nested-loop approach needs about n² comparisons; a sort-then-scan approach needs about n log n. For n = 1,000,000, that is ~10¹² operations versus ~2×10⁷ — hours versus seconds. This is why Big-O notation matters at the algorithm stage, long before coding.

3. Drawing the Flowchart

A flowchart is the algorithm's visual contract. Here are the standard flowchart symbols and meanings:

SymbolNameUsage
OvalTerminatorStart / End
ParallelogramInput/OutputRead / Print
RectangleProcessCalculation, assignment
DiamondDecisionCondition with labeled Yes/No exits
ArrowFlow lineDirection of control
Double-sided rectanglePredefined processSubprogram call
Small circleConnectorLinks flowchart across pages

Rule: every diamond must have ALL its exits labeled and handled.

Flowchart A — Pass/Fail check

+----------------+
       /  START (oval)  /
      +----------------+
                |
                v
      +-------------------+
     /  READ grade        /   (parallelogram)
    +-------------------+
                |
                v
        < grade >= 50 ? >----Yes----> +-------------------+
                |                    /  PRINT "Pass"     /
                No                  +-------------------+
                v                            |
      +-------------------+                  v
     /  PRINT "Fail"     /           +----------------+
    +-------------------+          /   END (oval)   /
                |                   +----------------+
                +---------------------------+
Flowchart B — Maximum-finding algorithm

START
  |
  v
READ n and first number
  |
  v
max ← first number, i ← 2
  |
  v
< i ≤ n ? >---No---> PRINT max ---> END
  |
 Yes
  v
READ num
  |
  v
< num > max ? >---Yes---> max ← num
  |                        |
 No                        |
  +--------> i ← i + 1 <---+
             |
             +----(back to "i ≤ n ?" decision)

Flowchart Rules and Common Mistakes

RuleMistake to avoid
Exactly one Start, at least one EndMultiple starts, no end (infinite loop)
Every decision has labeled exitsUnlabeled or missing "No" branch
One simple action per symbolCramming read+compute+print into one rectangle
Flow top-to-bottomSpaghetti flow that cannot be followed

Pseudocode vs. Flowchart

AspectPseudocodeFlowchart
Best forComplex logic, long algorithmsSimple logic, teaching, presentations
EditingEasy (plain text)Costly (redraw shapes)
Branching clarityReadableVisually obvious

4. How the Steps Map to Real Software Engineering

These steps mirror the software development life cycle (SDLC) used by professionals:

Beginner's stepProfessional equivalent
Problem analysisRequirements engineering
Algorithm designSystem design, data structures
Flowchart / pseudocodeUML and design documents
CodingImplementation
Trace tablesUnit testing, TDD
Problem Analysis → Algorithm Design → Flowchart/Pseudocode → Coding → Testing & Debugging
                                                      |                |
                                                      |   (errors: back to Algorithm Design)
                                                      v
                                        Documentation & Maintenance

5. Complete Worked Example: Class Average with Pass Count

Analysis: Input — number of students n, then n grades. Output — the average and the count of passes (grade ≥ 50). Constraints — n ≥ 1 and 0 ≤ grade ≤ 100.

START
  READ n
  sum ← 0; passes ← 0; i ← 1
  WHILE i ≤ n DO
    READ g
    sum ← sum + g
    IF g ≥ 50 THEN passes ← passes + 1 ENDIF
    i ← i + 1
  ENDWHILE
  average ← sum / n
  PRINT average, passes
END

Trace table (n = 3, grades 70, 45, 90):

igsumpasses
170701
2451151
3902052

Output: average = 205/3 ≈ 68.33, passes = 2 ✓

6. Summary: The Deep-Dive Checklist

StepDeep-level actions
AnalysisState the problem, define I/O, list constraints, decompose, hunt edge cases, write a test plan
AlgorithmUse only sequence/selection/iteration, refine stepwise, desk-check with trace tables, consider efficiency
FlowchartUse standard symbols, label every decision exit, verify one start/end, chart matches the pseudocode

The deeper lesson: programming is 80% thinking and 20% typing. Analysis defines the destination, the algorithm plots the route, the flowchart verifies the map — and the code is merely the drive.

Related keywords: problem solving in computer science · computational thinking · algorithm design for beginners · how to write pseudocode · flowchart symbols and meanings · steps of problem solving in programming · software development life cycle · IPO chart · trace table desk checking · control structures in programming · structured programming · divide and conquer problem solving · Big-O notation explained · requirements engineering basics · programming logic and design