Step 01 Beginner Problems — Fundamentals of Programming
Programming and What Are Computers?
Before writing programs it helps to know what a computer actually is and what it does with your code. A computer is not intelligent — it is an extremely fast, extremely obedient machine that executes simple instructions exactly as given. Understanding this model explains almost everything that follows in DSA: why algorithms are written as precise steps, and why we care about time and memory at all.
What is a computer, really?
Strip away the screen and apps and a computer does four things: it takes input (keyboard, files, sensors), processes it, stores data, and produces output. The processing is done by the CPU, which performs billions of tiny operations per second — add these two numbers, compare those two numbers, copy this value — each one laughably simple, but executed at staggering speed.
Two kinds of memory matter to you. RAM (main memory) is fast, temporary working space where your program's variables live while it runs; it is wiped when the program ends. Storage (SSD/hard disk) is slow but permanent. A core idea in DSA is that RAM is limited, so how much of it your algorithm uses (space complexity) genuinely matters.
What is a program?
A program is a precise sequence of instructions that tells the computer how to transform input into output. Three related words are worth separating now:
An algorithm is the idea — the step-by-step recipe, independent of any language. A program is that recipe written in a programming language. The running process is the program actually executing, with real data in memory.
Computers have zero judgement: they do exactly what you said, not what you meant. Almost every bug you will ever meet is a gap between those two things, which is why the field rewards precision and careful tracing.
How your code reaches the CPU
You write source code in a language like C++, Java or Python, but the CPU only understands machine code — binary instructions. A compiler (C++, Java) translates your whole program to machine code before it runs; an interpreter (Python) translates and executes it piece by piece while it runs, which is more flexible but slower.
While running, each variable is a named box in RAM holding a value. When you write x = x + 1, the CPU reads the value in box x, adds 1, and stores the result back. Keeping this 'boxes and instructions' picture in your head makes loops, arrays and recursion far easier to reason about later.
Why this matters for DSA
Every algorithm you write is ultimately a budget of CPU operations and RAM boxes. 'Optimising' means spending fewer of both. When an interviewer asks for a better solution, they are asking: can you get the same output with fewer operations, or less memory? Time and space complexity — which you meet properly in the Time Complexity lesson — are just disciplined ways of counting these two budgets before you run anything.
Key points
- A computer = input, processing (CPU), memory (RAM + storage), output — fast and literal, never smart.
- An algorithm is the language-independent recipe; a program is that recipe written in code.
- Compilers translate everything up front (C++/Java); interpreters translate while running (Python).
- Variables are named boxes in RAM; execution is the CPU reading, computing and storing, billions of times per second.
- DSA optimisation = fewer CPU operations and fewer memory boxes for the same result.