Articles / DSA · Part 1

What is DSA?

Learn DSA from the basics with this beginner-friendly guide to data structures and algorithms. Understand arrays, linked lists, stacks, queues, trees, graphs, searching, sorting, recursion, Big O notation, time and space complexity, and how DSA helps you solve programming problems efficiently.

What is DSA?

When you first start programming, everything seems simple.

You learn variables, conditions, loops, and functions. You write small programs, solve basic problems, and gradually become comfortable with code. Then you come across three letters: DSA.

Suddenly, you start hearing words like arrays, linked lists, stacks, queues, trees, graphs, recursion, searching, sorting, and Big O notation.

It can feel like a lot to learn.

But DSA is not just a collection of programming concepts or algorithms that you need to memorize. It is about understanding how information is organized and how problems can be solved efficiently.

Let’s understand what it actually means.

What Is DSA?

DSA stands for Data Structures and Algorithms.

It is the study of two closely connected concepts:

  • Data Structures: How we organize and store data.
  • Algorithms: The step-by-step procedures we use to process data and solve problems.

To understand why these two concepts matter, let’s look at them separately.

What Is a Data Structure?

A data structure is a way of organizing and storing data so that we can access, manage, and use it efficiently.

Suppose you are building a program to store the marks of five students. You could store them in separate variables:

int mark1 = 78;
int mark2 = 91;
int mark3 = 65;
int mark4 = 84;
int mark5 = 72;

This works perfectly well for five students. But what if you have 500 students? Or 10,000?

Creating a separate variable for every student’s marks would become difficult to manage. Instead, you could use an array:

int marks[5] = {78, 91, 65, 84, 72};

Now, all five values are stored together in an organized structure.

This is the basic idea behind a data structure.

Different problems require different ways of organizing information. For example, storing marks, managing a waiting list, representing a family tree, and recording connections between cities are different tasks. They may require different data structures.

Some commonly used data structures include:

  • Arrays
  • Strings
  • Linked Lists
  • Stacks
  • Queues
  • Trees
  • Graphs
  • Hash Tables
  • Heaps

We will study each of these throughout this series.

What Is an Algorithm?

An algorithm is a finite sequence of well-defined steps used to solve a problem or perform a particular task.

You already follow algorithms in everyday life without necessarily realizing it.

Think about making a cup of tea.

You might:

  1. Boil water.
  2. Add tea leaves.
  3. Add milk and sugar.
  4. Let it cook.
  5. Strain the tea.
  6. Serve it.

You follow a sequence of steps to achieve a particular result. This is a simple everyday example of an algorithm.

In programming, algorithms are more precise because computers follow instructions exactly as they are written. Let’s take another example.

Suppose you have an array of numbers: [12, 45, 7, 89, 23]

You want to find the largest number. How would you do it?

You could follow these steps:

  1. Start with the first number, 12, and assume it is the largest.
  2. Compare it with 45. Since 45 is larger, update the largest value to 45.
  3. Compare 45 with 7. Keep 45.
  4. Compare 45 with 89. Since 89 is larger, update the largest value to 89.
  5. Compare 89 with 23. Keep 89.
  6. After checking all the numbers, the largest value is 89.

These steps form an algorithm.

Notice that we didn’t need to check the numbers randomly. We followed a clear process and reached the correct answer.

That is what an algorithm does: it provides an organized approach to solving a problem.

Why Do We Need DSA?

You might be thinking: “If I can already write programs, why do I need to learn DSA?”

Because writing a program that works and writing a program that works efficiently are two different things.

“ Imagine you are developing a student management system for a university with 50,000 registered students. A student enters their registration number and expects the system to display their record. One possible approach is to check every student’s record, one by one, until the correct registration number is found. This approach can work, but it may become slow when the number of records increases. Another approach might use a suitable data structure that allows the system to locate records much more efficiently. Both approaches may produce the same result, but they can require very different amounts of time and memory.”

This difference becomes increasingly important as applications grow.

A program that works smoothly with 100 records might struggle when it has to process millions of records. DSA helps us understand how to choose appropriate ways of storing data and how to design better solutions for such problems.

Data Structures and Algorithms Work Together

Data structures and algorithms are not two unrelated subjects. They work together to solve problems.

The data structure determines how information is organized, while the algorithm determines how we perform operations on that information.

Let’s consider a simple example:

Suppose you are developing a music application where users can create playlists. You need to store songs, add new songs, remove existing ones, and move between tracks. You could use different data structures depending on how you want the playlist to work. Similarly, the application needs algorithms to perform operations such as searching for a song, arranging tracks, or finding a particular item.

The important thing to understand is that the way you organize data affects how efficiently you can work with it.

Choosing the right data structure and algorithm is therefore an important part of programming.

What Makes an Algorithm Good?

An algorithm should not only produce the correct answer. It should also solve the problem in a reasonable and efficient way.

Some important qualities of a good algorithm are:

  • Correctness: It should produce the expected result.
  • Efficiency: It should use time and memory reasonably.
  • Clarity: Its steps should be understandable.
  • Scalability: It should continue to work well as the amount of data increases.
  • Reliability: It should handle the situations it is designed to handle without producing unexpected results.

For example, imagine two algorithms that find the largest number in a collection. Both produce the correct answer. However, if one performs unnecessary operations and takes significantly longer, the other may be a better solution.

This is why we study the efficiency of algorithms.

In our third article, Space and Time Complexity in DSA, we will learn how to measure the resources an algorithm uses and understand concepts such as Big O notation.

DSA Is More About Thinking Than Coding

This is one of the most important things to understand when learning DSA. Many beginners approach DSA as a subject where they need to memorize the code for different algorithms. But memorizing code is not the same as understanding how to solve a problem.

For example, you might memorize the implementation of binary search. But if someone gives you a problem, can you recognize whether binary search is suitable for it?

That requires understanding.

The real process of solving a DSA problem involves asking yourself:

  • What exactly is the problem asking?
  • What information do I have?
  • How should I organize that information?
  • What steps can solve the problem?
  • Can I improve those steps to make the solution more efficient?

These questions develop your problem-solving ability.

The goal of learning DSA is not just to learn how to write code. It is to learn how to think before writing code.

What Will We Learn in This DSA Series?

We will begin with the fundamentals and gradually move towards more advanced concepts.

Here is the roadmap for this series:

Fundamentals

  1. What Is DSA? , Current Article
  2. Types of Data Structures: A Complete Overview
  3. Space and Time Complexity in DSA
  4. Data Types, Objects, and Data Structures: Representation and Implementation

Arrays and Linked Lists

  1. Arrays: Understanding the Basics
  2. Two-Dimensional Arrays, Matrix Operations, and Sparse Matrices
  3. Limitations and Applications of Linear Arrays
  4. Strings: Understanding String Data
  5. Linked Lists: How They Work (Types and Operations)
  6. Singly, Doubly, and Circular Linked Lists: A Deep Dive

Searching and Sorting

  1. Linear Search vs. Binary Search
  2. Bubble Sort, Selection Sort, and Insertion Sort
  3. Merge Sort and Quick Sort: A Comparative Guide
  4. Searching and Sorting Algorithms Compared

Stacks, Queues, and Recursion

  1. Stack Data Structure: Understanding LIFO
  2. Applications of Stacks: Parenthesis Checker, Infix to Postfix, and Evaluation
  3. Queue Data Structure: Understanding FIFO
  4. Circular Queues, Deques, and Priority Queues
  5. Heaps: Representation and Implementation of Priority Queues
  6. Recursion: Understanding the Basics

Trees and Graphs

  1. Trees: Definitions, Terminologies, and Properties
  2. Binary Trees: Representation, Traversals, and Applications
  3. Threaded Binary Trees, AVL Trees, and M-Way Search Trees
  4. B-Trees and B+ Trees: A Complete Guide
  5. Graphs: Terminology, Representations, and Traversal Techniques (BFS & DFS)
  6. Minimum Spanning Trees and Shortest Path Algorithms
  7. Eulerian Tour and Hamiltonian Tour

Hashing and Conclusion

  1. Hashing: Direct Address Tables, Hash Functions, and Collision Resolution
  2. Resolving Collisions: Chaining and Open Addressing (Rehashing)
  3. Conclusion

When learning something new, it is easy to become focused on completing topics rather than understanding them. Don’t approach DSA that way. Take time to understand why a particular data structure exists, what problem it solves, how it works, and when it should be used.

You don’t need to understand everything in one day. Build your understanding step by step, practise what you learn, and try solving problems on your own.

By the end of this series, the aim is not simply to recognize the names of different data structures and algorithms, but to understand how to use them when solving real programming problems.

Let’s start building that understanding, one concept at a time.

Read the original source

Keep a copy

Read offline as a printout or PDF.

farhanpaal.com

Keep reading

DSA · Part 3

Space and Time Complexity in DSA

Understand time complexity, space complexity, Big O notation, and how to analyse algorithm efficiency with simple examples.

8 min read
DSA · Part 27

Eulerian Tour and Hamiltonian Tour

Understand Eulerian and Hamiltonian paths and tours, their conditions, differences, examples, and real-world applications in graph theory.

4 min read

Ask Farhan

Ask anything about Farhan