This DSA series is my learning-in-public journey.
I’m not pretending to be a 10x engineer — I’m learning concepts properly and writing them down so future-me (and you) don’t suffer again.


What Is an Array? (No Fancy Words Yet)

An array is just a collection of items stored next to each other in memory.

That’s it.
No hype. No buzzwords.

Think of it like:

  • A row of lockers 🧳
  • An egg tray 🥚
  • A Netflix playlist (ordered, indexed, sometimes disappointing)

Each item has a position, called an index.

Index:  0   1   2   3   4
Value: [5, 10, 15, 20, 25]

Yes, indexing starts at 0.
Computers decided this long ago and we just live with it.


Real-World Analogy (Includes Suffering)

Imagine you booked 5 adjacent seats in a movie theatre 🎬

Seat numbers:

0 | 1 | 2 | 3 | 4
  • Want seat #3? You go directly there. No searching.
  • Someone wants to sit between seats #1 and #2?

Everyone after that has to stand up and move 😤

That’s arrays in real life:

  • Fast access
  • Painful insertions in the middle

Arrays in Python (The Friendly Version)

Python doesn’t expose low-level arrays like C/C++.

Instead, we use lists, which behave like arrays for DSA purposes.

numbers = [10, 20, 30, 40, 50]

You’ll solve 90% of array problems using Python lists.
That’s perfectly fine.


Accessing Elements (Why Arrays Are Loved)

print(numbers[2])  # 30

This is O(1) — instant.

Why? Because arrays calculate the memory address directly instead of searching.

No loop.
No drama.
Just vibes.


Common Operations (Good, Bad, Ugly)

1️⃣ Access — Life Is Good

numbers[0]  # O(1)
numbers[4]  # O(1)

Direct access is the superpower of arrays.


2️⃣ Insert at the End — Still Okay

numbers.append(60)

This is amortized O(1).

Python secretly allocates extra space ahead of time like:

“What if you add more later?”

Smart move.


3️⃣ Insert in the Middle — Pain Begins

numbers.insert(2, 25)

Time Complexity: O(n)

Why? Because every element after index 2 must shift right.

Your CPU sighs.
Your algorithm slows.
Your interviewer watches silently.


4️⃣ Deleting Elements — Depends Where

numbers.pop()     # O(1)
numbers.pop(2)    # O(n)

Deleting from the middle = same shifting pain.


Why Arrays Still Matter (Even With Better Options)

Arrays are foundational.

You’ll see them everywhere:

  • Sorting algorithms
  • Two pointer problems
  • Sliding window patterns
  • Prefix sums
  • Almost every interview question ever

Arrays are like:

“I’m not perfect, but everything else is built on me.”


Time & Space Complexity (Human Version)

OperationTime Complexity
AccessO(1)
UpdateO(1)
Insert at endO(1)*
Insert in middleO(n)
DeleteO(n)
Search (unsorted)O(n)

* amortized — meaning “usually fast, occasionally slow, overall fine”.

Space Complexity

  • O(n) — you store n elements
  • No hidden magic
  • No secret memory leaks

Classic Beginner Mistakes (We All Did These)

❌ Assuming indexing starts at 1
❌ Forgetting bounds (IndexError trauma)
❌ Using arrays where frequent insertions are needed
❌ Overengineering simple problems

Bonus classic:

arr = [[0]] * 3
arr[0][0] = 1
print(arr)

Result:

[[1], [1], [1]]

Pain level: maximum


Meme Break 🧠

Arrays are fast
Until you touch the middle
Then they choose violence


When NOT to Use Arrays

Avoid arrays when:

  • Frequent insertions/deletions in the middle
  • Size changes constantly
  • Fast search + modification is required

That’s when:

  • Linked Lists
  • Sets
  • Hash Maps

enter the chat.


Interview Reality Check

If a problem starts with:

“Given an array…”

They expect you to:

  • Use indices smartly
  • Minimize extra space
  • Recognize patterns (two pointers, sliding window)

Arrays are rarely just arrays in interviews.


TL;DR (Save This)

  • Arrays store elements contiguously
  • Access is O(1)
  • Middle insert/delete is O(n)
  • Python lists act like arrays
  • Master arrays → DSA becomes easier

Coming Up Next

  • Time & Space Complexity (explained like money budgeting)
  • Two Pointers Pattern
  • Sliding Window (arrays on steroids)

Learning in public. One concept at a time 🚀