How to Solve Any Problem with a Computer: Analysis, Algorithms & Flowcharts
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.
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
| Stage | Question it answers | Output |
|---|---|---|
| Understanding | What is the problem in plain words? | One-sentence problem statement |
| Specification | What are the inputs, outputs, formulas? | Formal input/output contract |
| Decomposition | Can it be broken into subproblems? | List of smaller tasks |
| Constraints | What 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:
| Input | Process | Output |
|---|---|---|
| Number of students n, then n grades | Sum the grades, divide by n | Average = (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
| Type | Description | Example |
|---|---|---|
| Functional | What the program computes | "Convert Fahrenheit to Celsius" |
| Non-functional | How 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:
| Structure | Purpose | Pseudocode pattern |
|---|---|---|
| Sequence | Steps in order | step1; step2 |
| Selection | Choosing between paths | IF condition THEN ... ELSE ... |
| Iteration | Repeating steps | WHILE 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:
- ReadData (name, marks in 3 subjects)
- ComputeAverage (sum ÷ 3)
- DetermineGrade (average → A/B/C/D/F)
- 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:
| Iteration | num | num > max? | max after |
|---|---|---|---|
| Initial | 3 | — | 3 |
| 1 | 9 | Yes | 9 |
| 2 | 2 | No | 9 |
Expected output: 9 ✓
Algorithm Quality Criteria
| Criterion | Question |
|---|---|
| Correctness | Right output for ALL valid inputs? |
| Efficiency | How do time and memory grow with input size? |
| Simplicity | Can another person read and understand it? |
| Generality | Does 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:
| Symbol | Name | Usage |
|---|---|---|
| Oval | Terminator | Start / End |
| Parallelogram | Input/Output | Read / Print |
| Rectangle | Process | Calculation, assignment |
| Diamond | Decision | Condition with labeled Yes/No exits |
| Arrow | Flow line | Direction of control |
| Double-sided rectangle | Predefined process | Subprogram call |
| Small circle | Connector | Links 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
| Rule | Mistake to avoid |
|---|---|
| Exactly one Start, at least one End | Multiple starts, no end (infinite loop) |
| Every decision has labeled exits | Unlabeled or missing "No" branch |
| One simple action per symbol | Cramming read+compute+print into one rectangle |
| Flow top-to-bottom | Spaghetti flow that cannot be followed |
Pseudocode vs. Flowchart
| Aspect | Pseudocode | Flowchart |
|---|---|---|
| Best for | Complex logic, long algorithms | Simple logic, teaching, presentations |
| Editing | Easy (plain text) | Costly (redraw shapes) |
| Branching clarity | Readable | Visually obvious |
4. How the Steps Map to Real Software Engineering
These steps mirror the software development life cycle (SDLC) used by professionals:
| Beginner's step | Professional equivalent |
|---|---|
| Problem analysis | Requirements engineering |
| Algorithm design | System design, data structures |
| Flowchart / pseudocode | UML and design documents |
| Coding | Implementation |
| Trace tables | Unit 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):
| i | g | sum | passes |
|---|---|---|---|
| 1 | 70 | 70 | 1 |
| 2 | 45 | 115 | 1 |
| 3 | 90 | 205 | 2 |
Output: average = 205/3 ≈ 68.33, passes = 2 ✓
6. Summary: The Deep-Dive Checklist
| Step | Deep-level actions |
|---|---|
| Analysis | State the problem, define I/O, list constraints, decompose, hunt edge cases, write a test plan |
| Algorithm | Use only sequence/selection/iteration, refine stepwise, desk-check with trace tables, consider efficiency |
| Flowchart | Use 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
Share this article
