Before We Write Code
What DSA is, why it matters, how computers store data, and your first C program.
Quick answer
Data structures are ways of organising data in memory (arrays, lists, trees, hash tables) and algorithms are step-by-step procedures that work on them (searching, sorting). Interviews test DSA because it shows how you reason about speed and memory.
- Every variable lives at an address in memory; its name is just a label.
- The right structure can turn a slow program into a fast one.
- This track uses C because it shows exactly what happens in memory.
#include <stdio.h>
int main(void) {
int orders = 42;
double total = 129.50;
printf("orders = %d, total = %.2f\n", orders, total);
printf("orders uses %zu bytes, total uses %zu bytes\n", sizeof orders, sizeof total);
return 0;
}Output
orders = 42, total = 129.50 orders uses 4 bytes, total uses 8 bytes
Before we write a single line of code, we need to answer four honest questions. What is DSA? Why do companies test it? How does a computer actually store your data? And why are we using C instead of Python or JavaScript?
This lesson is for everyone — especially those who have never written code before, or who come from a non-IT background. If you already know some programming, you will still find the memory and computer internals section useful. Read it anyway.
What is Data Structures & Algorithms?
Let's start with the two words separately — because most explanations combine them too early and create confusion.
📦 Data Structure = How you organise your data
Imagine you are moving to a new house. You have 200 items — clothes, books, utensils, documents. Now you have two choices:
A data structure is that labelled box system — but for data inside a computer. It is a way of organising information so you can find it, change it, and use it efficiently.
📋 Algorithm = Step-by-step instructions to solve a problem
You already use algorithms every day without knowing it. When you make tea:
Step 2: Add tea leaves
Step 3: Wait 3 minutes
Step 4: Add milk and sugar
Step 5: Pour and serve
That is an algorithm. A fixed set of steps that, if followed correctly, always produces the right result. In programming, an algorithm is the same thing — a clear sequence of steps to solve a specific problem, written in code.
Why Does Every Tech Company Test DSA?
If you have ever looked at a software job description, you have seen this: "Data Structures and Algorithms round." You may have wondered — why? I just want to build websites. Why do I need to know how to reverse a linked list?
Here is the honest answer.
How Your Computer Actually Stores Data
This section is something most tutorials completely skip. They just say "create a variable" and move on. We are not going to do that — because if you do not understand what happens in memory, a huge part of DSA will always feel like magic tricks instead of logic.
Think of RAM as a street full of houses
Your computer's RAM (Random Access Memory) is where all active data lives while a program is running. Think of it as a very long street with millions of tiny houses. Each house has a unique address and can hold exactly one small piece of information.
Each box = one memory cell. Each address = its location. Data sits inside.
When you write int age = 25 in a program, your computer does three things:
Why Are We Using C?
You might be wondering — everyone online uses Python or Java for DSA. Why are we doing this in C? Good question. Here is the full honest answer.
Your First C Program — Line by Line
Let us write actual code. This is the most classic program in all of programming — printing "Hello, World!" on the screen. We are going to explain every single line so nothing is a mystery.
Now let us work with variables
A variable is a named box in memory that holds a value. In C, you must always say what type of value the box will hold. This is called a data type.
| Type | What it stores | Example | Memory size |
|---|---|---|---|
| int | Whole numbers | 5, -3, 1000 | 4 bytes |
| float | Decimal numbers | 3.14, -0.5 | 4 bytes |
| char | A single character | 'A', 'z', '9' | 1 byte |
| double | High-precision decimal | 3.14159265 | 8 bytes |
The %d, %f, and %c are format specifiers — placeholders that tell printf what type of value to print. The actual variable comes after the comma.
Taking input from the user
Notice the &number — that ampersand (&) means "the memory address of number." scanf needs to know where to store the value you type, so you give it the address.
& symbol you just saw is the beginning of pointers. You gave scanf the address of a variable so it could write directly into memory. That exact idea — working with addresses — is how linked lists, trees, and graphs are built. You have already touched the most important concept in C.Decisions and loops — the last basics you need
i = 1i <= 5i++You Are Ready for Lesson 2
You now know what DSA is, why it matters, how memory works, why we use C, and the basics of writing C programs. That is the complete foundation.
In Lesson 2, we tackle Complexity — how to measure the speed and memory usage of any piece of code. This is the skill that separates engineers who write code from engineers who write good code.
🎯 Key Takeaways
- ✓DSA = Data Structures (how data is organised) + Algorithms (step-by-step instructions to solve problems)
- ✓Companies test DSA because it reveals how you think — not just what frameworks you know
- ✓Every variable lives at a specific address in RAM. The variable name is just a human label
- ✓We use C because it hides nothing — you see exactly what happens in memory
- ✓#include <stdio.h> imports print tools. int main() is the entry point. printf prints. return 0 means success
- ✓int, float, char, double are the four basic data types. Use %d, %f, %c to print them
- ✓The & in scanf gives the memory address of a variable — your first glimpse of pointers
Quick check
What is an algorithm?
HELP US IMPROVE
How was this lesson?
Your note is shared with the Chaduvuko team for review. Please don’t include personal or sensitive information.
Spotted a mistake or something unclear? Suggest a fix on GitHub or email us. Select the text first and it is quoted for you.
Discussion
0Have a better approach? Found something outdated? Share it — your knowledge helps everyone learning here.
