CS Fundamentals
Learn what algorithms are, how to write them, and how to represent them visually using flowcharts — foundational skills for any programmer.
Introduction
Before you can write a program, you need to solve the problem on paper. Writing code is just the final step — translating your solution into a language the computer understands. The real intellectual work is figuring out the solution itself: what steps are needed, in what order, and what decisions must be made along the way. This is where algorithms and flowcharts come in.
An algorithm is a step-by-step procedure for solving a problem, written in plain language. A flowchart is a visual diagram that represents the same procedure using standard symbols. Together, they are the planning tools that every programmer uses before writing code. Jumping straight to coding without planning is like building a house without a blueprint — you might get something standing, but it will be inefficient, error-prone, and hard to fix.
What Is an Algorithm?
An algorithm is a finite set of well-defined instructions for solving a specific problem or performing a specific task. Think of a recipe for making tea: (1) boil water, (2) add tea leaves, (3) wait 3 minutes, (4) strain into cup, (5) add sugar if desired, (6) serve. This is an algorithm — clear, sequential steps that anyone can follow to achieve the desired result.
For an algorithm to be valid, it must have five properties. Finiteness means the algorithm must eventually terminate — it cannot run forever. Definiteness means each step must be precisely and unambiguously defined — there should be no confusion about what to do. Input means the algorithm receives zero or more inputs (data to work with). Output means the algorithm produces at least one output (the result). Effectiveness means every step must be basic enough to be carried out (in principle) by a person using pencil and paper.
Writing Algorithms — Examples
Let us write algorithms for increasingly complex problems.
Algorithm to find the sum of two numbers: Step 1, Start. Step 2, Read two numbers A and B. Step 3, Calculate Sum = A + B. Step 4, Display Sum. Step 5, Stop.
Algorithm to check if a number is even or odd: Step 1, Start. Step 2, Read a number N. Step 3, Calculate Remainder = N mod 2. Step 4, If Remainder equals 0, then display "N is Even." Step 5, Else, display "N is Odd." Step 6, Stop.
Algorithm to find the largest of three numbers: Step 1, Start. Step 2, Read three numbers A, B, and C. Step 3, If A is greater than B AND A is greater than C, then Largest = A. Step 4, Else if B is greater than A AND B is greater than C, then Largest = B. Step 5, Else, Largest = C. Step 6, Display Largest. Step 7, Stop.
Algorithm to find the sum of first N natural numbers: Step 1, Start. Step 2, Read N. Step 3, Set Sum = 0 and Counter = 1. Step 4, While Counter is less than or equal to N, do: Add Counter to Sum, then Increment Counter by 1. Step 5, Display Sum. Step 6, Stop.
Notice how algorithms involve three fundamental control structures: sequence (steps executed one after another), selection (making decisions — if/else), and iteration (repeating steps — while/for loops). Every algorithm, no matter how complex, is built from combinations of these three structures.
What Is a Flowchart?
A flowchart is a diagrammatic representation of an algorithm using standard symbols connected by arrows showing the flow of execution. Flowcharts make algorithms visual, which helps with understanding logic flow, identifying errors, and communicating procedures to others.
Standard flowchart symbols include: Oval (Terminal) representing Start and End points. Rectangle (Process) representing actions, calculations, or assignments. Diamond (Decision) representing questions with Yes/No or True/False branches. Parallelogram (Input/Output) representing data being read or results being displayed. Arrow (Flow Line) showing the direction of execution from one step to the next.
Drawing Flowcharts — Examples
For the algorithm to check even or odd: Draw an oval labeled "Start." Connect with an arrow to a parallelogram labeled "Read N." Connect to a diamond labeled "N mod 2 = 0?" with two branches — "Yes" leads to a parallelogram "Display Even" and "No" leads to a parallelogram "Display Odd." Both connect to an oval labeled "Stop."
For the sum of N numbers: Start oval connects to "Read N" parallelogram, connects to "Sum = 0, Counter = 1" rectangle, connects to a diamond "Counter <= N?" The "Yes" branch goes to "Sum = Sum + Counter" rectangle, then "Counter = Counter + 1" rectangle, which loops back to the decision diamond. The "No" branch goes to "Display Sum" parallelogram, then "Stop" oval.
The key principle is that every flowchart has exactly one Start and one Stop, decision diamonds always have exactly two exit paths (yes/no), and arrows clearly show which path execution follows.
Pseudocode — A Middle Ground
Pseudocode is a way of writing algorithms that looks like programming code but uses plain English. It is more structured than a plain-English algorithm but not tied to any specific programming language syntax.
Example pseudocode for finding the largest of three numbers:
Pseudocode is useful because it is closer to actual code (making translation easier) while remaining readable to non-programmers. Many textbooks and exam questions ask you to write solutions in pseudocode.
Why Algorithms and Flowcharts Matter
Planning before coding saves time overall. You catch logical errors on paper before spending hours debugging code. Flowcharts help you visualize the complete logic including all possible paths — when you draw out all the decision branches, you often discover cases you had not considered.
In exams, questions about writing algorithms or drawing flowcharts are extremely common. Examiners are testing whether you can think logically and solve problems systematically — the fundamental skill underlying all programming.
In professional software development, algorithms remain critical. While you may not draw flowcharts for simple functions, complex system logic is always planned on whiteboards, in design documents, or through pseudocode before implementation begins.
Key Takeaways
- An algorithm is a step-by-step problem-solving procedure with five properties: finite, definite, input, output, effective
- Every algorithm uses three control structures: sequence, selection (decisions), and iteration (loops)
- Flowcharts represent algorithms visually using standard symbols: oval, rectangle, diamond, parallelogram, arrows
- Practice writing algorithms for common problems — it builds the logical thinking essential for programming
- Pseudocode bridges the gap between plain-English algorithms and actual programming code
- Always plan (algorithm/flowchart) before coding — it saves time and catches errors early
- Exam tip: draw flowcharts neatly with clear labels and consistent symbol sizes for maximum marks
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for Algorithms and Flowcharts.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this Computer Fundamentals topic.
Search Terms
computer-fundamentals, computer fundamentals, computer, fundamentals, programming, algorithms, and, flowcharts
Related Computer Fundamentals Topics