DSA Bloom logo
DSA BLOOM / DATA STRUCTURES

Build Strong.
Think Structurally.

Master the structures that organize information behind efficient software — from Arrays and Linked Lists to Trees, Graphs, Hash Tables, and Heaps.

Arrays Linked Lists Stacks & Queues Trees Graphs Hash Tables
Explore Data Structure Lessons

Data Structures Lessons

Array

What is a Data Structure?

A Data Structure is a way to organize and store data in a computer so it can be used easily.

For example, a program may store:
numbers,names, messages, images
If data is not organized, the computer cannot work with it efficiently.

So we use data structures to store and manage data properly.

Linked List

Why Do We Need Data Structures?

Data structures help us to:

1. Store data efficiently
2. Find data quickly
3. Update data easily
4. Process large amounts of data
5. Without data structures, programs would become slow and difficult to manage.
6. Big systems like social media, banking apps, and search engines all use data structures.

Linked List

Types of Data Structures?

There are many kinds of data structures. The most common ones are:

Basic Data Structures
Array
Linked List
Stack
Queue

Advanced Data Structures
Tree
Graph
Hash Table
Heap

We will learn each one step by step with examples and code.

Linked List

What is an Array?

An Array is a data structure used to store multiple values in one variable.
Instead of creating many variables, we store everything inside one array.

Example:
let numbers = [10, 20, 30, 40];
Here the array stores 4 values.

Linked List

Array Index

Each value in an array has a position number called an index.

Important rule:
Array index always starts from 0

Example:
let numbers = [10, 20, 30, 40];
Index Value
0 - 10
1 - 20
2 - 30
3 - 40

Accessing values:
numbers[0] → 10
numbers[2] → 30

Linked List

Basic Array Operations

Common things we do with arrays:

1 Access value
numbers[1]

2 Add value
numbers.push(50)

3 Remove value
numbers.pop()

4 Change value
numbers[0] = 100

Arrays are very fast for accessing data using index.

Linked List

What is Time Complexity?

Time Complexity means:
How much time a program takes to run

We don’t measure time in seconds.
We measure how the time grows when input increases.

Example idea:
Small data → fast
Big data → slower

Time complexity helps us understand how efficient our code is.

Linked List

Big O Notation:

We use something called Big O Notation to describe time complexity.

It looks like this:

O(1) → very fast (constant time)
O(n) → grows with input
O(n²) → slower (nested loops)

Example:
for(let i = 0; i < n; i++){
console.log(i);
}

This is O(n) because it runs n times.

Linked List

Common Time Complexities:

Here are the most important ones:

⚡ O(1) – Constant
Always same speed
Example:
numbers[0]

🚶 O(n) – Linear
Depends on input size
Example:
for(let i = 0; i < n; i++){}

🐢 O(n²) – Quadratic
Very slow for big data
Example:
for(let i = 0; i < n; i++){
for(let j = 0; j < n; j++){}
}

💡 Simple idea:
O(1) → best
O(n) → okay
O(n²) → avoid if possible

Linked List

What is a Linked List?

A Linked List is a data structure where:
👉 Each item (node) is connected to the next item

It is like a chain:
[10] → [20] → [30] → [40]
Each part is called a node.

Linked List

Structure of a Node:

Structure of a Node

Each node has 2 parts:

1 Data → the value (like 10, 20)
2 Next → a link to the next node

Example:
let node = {
data: 10,
next: null
}

Chain example:
10 → 20 → 30 → null
👉 null means end of list

Linked List

Linked List vs Array:

Array
Fixed size (or harder to change)
Fast access using index
Example: arr[2]

Linked List
Dynamic size (can grow easily)
No index
Must go step by step to find data

💡 Simple idea:
Array = fast access
Linked List = flexible size

Linked List

Traversing a Linked List:

Traverse means:

👉 Go through all nodes one by one
Since there is no index, we must start from the beginning.

Example:
let current = head;
while(current !== null){
console.log(current.data);
current = current.next;
}
💡 This prints all values in the list.

Linked List

Inserting Data into a Linked List:

👉 Insert at beginning
let newNode = {
data: 5,
next: head
};
head = newNode;
Now list becomes:
5 → 10 → 20 → 30

👉 Insert at end
let newNode = {
data: 50,
next: null
};
let current = head;
while(current.next !== null){
current = current.next;
}
current.next = newNode;

Linked List

Deleting Data from a Linked List:

👉 Delete first node
head = head.next;

👉 Delete specific value
let current = head;
while(current.next !== null){
if(current.next.data === 20){
current.next = current.next.next;
break;
}
current = current.next;
}

💡 Simple idea:
Traverse → read data
Insert → add node
Delete → remove node

Linked List

What is a Stack?

A Stack is a data structure that follows:
👉 LIFO (Last In, First Out)

Meaning:
The last item you add is the first one you remove

Example:
[10, 20, 30]
👉 30 will be removed first


Linked List

Stack Operations:

1 Push (Add item)
stack.push(40)
Now:
[10, 20, 30, 40]

2 Pop (Remove item)
stack.pop()
Removes 40

3 Peek (See top item)
stack[stack.length - 1]
Shows last value without removing it
💡 Stack always works from the top

Linked List

What is a Queue?

A Queue is a data structure that follows:
👉 FIFO (First In, First Out)

Meaning:
First item added is the first one removed

Example:
[10, 20, 30]
👉 10 will be removed first

Linked List

Queue Operations:

1 Enqueue (Add item)
queue.push(40)

2 Dequeue (Remove item)
queue.shift()
Removes first item

3 Front (See first item)
queue[0]

💡 Simple idea:
Stack → last comes out first
Queue → first comes out first

Linked List

What is a Tree?

A Tree is a data structure that looks like a hierarchy.
It starts from one top node and branches down.
Example:
10
/   \
20 30
/  \
40 50

Important Terms:
Root → top node (10)
Parent → node with children (20)
Child → node below (40, 50)
Leaf → node with no children (40, 50, 30)

💡 Trees are used in:
File systems
Databases
Searching

Linked List

Binary Tree:

A Binary Tree is a tree where:
👉 Each node can have maximum 2 children
Left child
Right child
Example:
10
/   \
20 30

💡 Rule:
Each node → at most 2 children

Linked List

Queue Operations:

A BST is a special binary tree with rules:
👉 Left side → smaller values
👉 Right side → bigger values
Example:
10
/   \
5   20
/  \   \
2   7   30
Why BST is powerful?

Because it makes searching very fast
👉 Like binary search

Linked List

Tree Traversal:

Traversal means:
👉 Visiting all nodes
Types:
1 Inorder (Left → Root → Right)
Left → Root → Right

2 Preorder (Root → Left → Right)
Root → Left → Right

3 Postorder (Left → Right → Root)
Left → Right → Root

💡 Traversal is used to:
Read data
Process trees

Linked List

What is a Graph?

A Graph is a data structure used to show connections between things.
It has:
Nodes (Vertices) → points
Edges → connections between nodes
Example:
A — B
|        |
C — D

💡 Real life examples:
Social networks
Maps (cities & roads)
Internet connections

Linked List

Types of Graphs:

1 Undirected Graph
Connection goes both ways
A — B
👉 A is connected to B and B to A

2 Directed Graph
Connection has direction
A → B
👉 Only A goes to B

3 Weighted Graph
Edges have values (distance, cost)
A —5— B
👉 Cost from A to B is 5

Linked List

Graph Traversal:

Traversal means:
👉 Visiting all nodes

🔵 BFS (Breadth First Search)
Goes level by level
Uses Queue

Example flow:
A → B → C → D

🔴 DFS (Depth First Search)
Goes deep first
Uses Stack

Example flow:
A → B → D → C

💡 Simple idea:
BFS → wide (level)
DFS → deep

Linked List

Hash Table:

A Hash Table stores data in key-value pairs.
Example:
{
name: "Zohil",
age: 20
}

Why use Hash Table?
👉 Very fast access
data["name"] // very fast

💡 Used in:
Databases
Caching
APIs

Linked List

Heap:

A Heap is a special tree used for priority.

Types:

🔹 Min Heap
Smallest value on top

🔹 Max Heap
Largest value on top
Example (Min Heap):
 5
/   \
10  20

💡 Used in:
Priority queues
Scheduling
Algorithms

Linked List

Sorting Algorithms:

Sorting means:
👉 Arranging data in order (small → big or big → small)

Example:
[5, 2, 9, 1] → [1, 2, 5, 9]

Common Sorting Types:

1 Bubble Sort
Compare and swap values
Simple but slow
👉 Time: O(n²)

2 Selection Sort
Find smallest and place it first
👉 Time: O(n²)

3 Quick Sort (Important)
Divide and sort
👉 Time: O(n log n) (fast)

💡 Simple idea:
Small data → any sort works
Big data → use Quick Sort

Linked List

Searching Algorithms:

Searching means:
👉 Finding a value

1 Linear Search
Check one by one
for(let i = 0; i < arr.length; i++){
if(arr[i] === x) return i;
}
👉 Time: O(n)

2 Binary Search (Very Important)
👉 Works only on sorted array
Steps:
Check middle
Go left or right
👉 Time: O(log n) (very fast)

Linked List

Recursion:

Recursion means:
👉 A function calling itself

Example:
function count(n){
if(n === 0) return;
console.log(n);
count(n - 1);
}

💡 Important:
Every recursion must have:
Base case (stop condition)
Recursive call

Linked List

Practice Problems:

To become strong 💪 you must practice:

Examples:
Reverse array
Find max/min
Palindrome check
Stack/Queue problems
Tree traversal
👉 Practice = real learning

Linked List

Mini-Project + Interview Prep:

🛠 Mini Project Ideas:
Task Manager (use arrays + stack)
Contact list (use hash table)
Simple search system


Linked List

Interview Tips:

Understand concepts (not memorize)
Practice coding daily

Focus on:
Arrays
Strings
Trees
Graphs

Linked List

Congratulations!