Single logo
  • Courses
  • Blog
  • About
Join on SkoolJoin on Skool

In this topic

Data Structures and Algorithms
  • What a Data Structure Is, and How Memory Works
  • Arrays and Dynamic Arrays: Full? Get a Box Twice the Size
  • Linked Lists: A Chain of Clues, Built in Python
  • Stacks: Last In, First Out, With the Undo Button
  • Queues: First In, First Out, With a Ring of Cells
  • Hash Tables: The Name Tells You Where to Look
  • Binary Search Trees: Smaller Left, Bigger Right, Half Gone at Every Look
  • Tree Traversals: In-Order, Pre-Order and Post-Order as a Tour of the House
  • Heaps and Priority Queues: Most Urgent First, Without Searching the Room
  • Graphs and Breadth-First Search (BFS): Fewest Hops, Level by Level
  • Big-O: Reading Cost From Code, With Handshakes and a Guest Book
  • Recursion: Russian Dolls, the Base Case and the Call Stack
  • Linear vs Binary Search: Page by Page, or Open in the Middle
  • Insertion Sort: Take the Next Card and Slide It Left Until It Fits
  • Merge Sort: Split the Pile, Then Merge Two Sorted Piles
  • Quick Sort: Line Up Around One Friend, Then Repeat on Each Side
  • Depth-First Search (DFS): Go Deep, Back Up, Mark Where You've Been
  • The Two Pointers Technique: Find a Pair in One Pass Instead of Every Pair
  • The Sliding Window Technique: One In, One Out
  • Greedy Algorithms: The Best-Looking Choice, Right Now
  • Dynamic Programming: Work It Out Once, Write It Down, Read It Back
  1. Blog
  2. /
  3. Data Structures and Algorithms
  4. /
  5. Data Structures

What a Data Structure Is, and How Memory Works

Memory is a long row of numbered boxes, and opening any box is equally quick. A data structure is an agreed way of arranging things in those boxes, plus a few small notes. See with six songs on a phone why every structure is quick at some things and slow at others.

Chaand Sheikh

·27 November 2026·Updated 28 November 2026Data Structures

What you will learn

  • Picture memory as a row of numbered boxes that are all equally quick to open
  • Explain why one sum reaches any item in a gap-free row
  • Explain why adding at the front of a row means moving everything
  • Describe a data structure as an arrangement of boxes plus small notes

Before you start

  • No coding needed

Before you learn a single data structure, it helps to know what memory really is. The idea is simple. Memory is a long row of numbered boxes, and opening any box is equally quick. A data structure is just an agreed way of arranging things in those boxes, plus a few small notes.

That one idea explains why every structure you'll meet is quick at some things and slow at others. No code needed here; just pictures.

Six songs on a phone

Maya has a phone with six songs: Rain, Moon, Fire, Sea, Wind and Snow. She taps song number five, and Wind plays at once. No waiting.

So how did the phone find Wind so fast? Did it look through songs one to four first? It didn't, and the reason comes from how memory is built.

A wall of numbered lockers

Imagine a long wall of lockers, each with a number on the door: 200, 201, 202, and so on. A locker holds one thing only. Rain goes in 200, Moon in 201, Fire in 202, Sea in 203, Wind in 204 and Snow in 205. One song per locker, with no empty locker in between.

The phone remembers just two things: where the songs start (200) and how many there are (6). When Maya taps song 5, the phone skips the 4 songs in front of it. 200 plus 4 is 204, and locker 204 opens. Nothing was searched. A computer never walks along the wall; it goes straight to the number.

One sum opens one box 200201202203204205206207208209 RainMoonFireSeaWindSnow notes: start = 200count = 6 song 5: skip 4 songs200 + 4 = 204, one box opened
No gaps, two notes, one sum. Song 2 is 200 + 1 = 201 and song 6 is 200 + 5 = 205. Song 7 is refused, because the notes say there are only 6.

Whichever song she picks, it's one sum and one box. That's why reaching an item by its position in a gap-free row costs the same, however long the row gets.

Adding at the front

Now see where this breaks. Maya wants to add a new song, Star, right at the front. Star needs box 200, so every song has to shift one box along.

And you start at the far end. If Rain moved first, it would land on top of Moon and wipe it out. So Snow goes from 205 to 206, then Wind from 204 to 205, then Sea, Fire, Moon and Rain each move one box along. Six songs have moved. Now box 200 is free, Star goes in, and the notes say 7 songs.

If one more song arrives, it needs box 207. But that box belongs to another app. So all 7 songs have to be copied into a free run of 8 boxes. No gaps is why the sum works, and it's also why this hurts.

Same boxes, new arrangement

So what does a data structure add? Put the same six songs into boxes scattered all over memory: Rain in 317, Moon in 142, Fire in 508, Sea in 263, Wind in 91 and Snow in 430. Each song now carries a small note with the number of the next box.

Scattered boxes joined by next-box notes Starnext: 317 Rain 317next: 142 Moon 142next: 508 Fire 508next: 263 Sea 263next: 91 Wind 91next: 430 Snow 430next: none song 5: open 317, 142, 508, 263, 91 (5 boxes) add Star at the front: new box + changed start note = 2 changes
Same songs, same boxes. Different arrangement, different notes, different costs.

To reach the fifth song you open 317, then 142, then 508, then 263, and finally 91. That's 5 boxes opened, not one. But adding Star at the front is now easy. Star gets any free box with a note pointing to 317, and the start note changes. Two changes, and not one song moved.

The boxes never changed. Only the arrangement and the notes did.

What happens when the list grows

JobNumbered row, 6 songsNumbered row, a millionChain, 6 songsChain, a million
Reach the last song1 sum1 sum6 boxesa million boxes
Add at the frontmove 6 songsmove a million2 changes2 changes

In plain words: in the row, reaching any song is one sum and one box, but adding at the front moves every song. In the chain, reaching the last song means following the notes through every box, but adding at the front is one new box and a changed start note. No structure wins at everything.

Later lessons write these costs in Big-O notation: one sum is O(1), and work that grows with the number of songs is O(n). The Big-O lesson covers that.

Where this goes next

The rest of the course follows four groups. First, things in a line: rows, chains, stacks and queues (think undo and print jobs). Second, finding fast: hash tables, sorted trees and heaps (think contacts and database lookups). Third, connected things: graphs and shortest paths (the route on a map). Fourth, methods: searching, sorting and smart ways to solve problems.

Each time, ask the same three questions. How is it arranged, what's quick, and what's slow?

Recap

  • Memory is a row of numbered boxes, and one sum takes you straight to one box.
  • No gaps is why the sum works, and it's also why adding at the front means moving everything.
  • A data structure is an arrangement of boxes plus small notes, and that decides what's quick and what's slow.

Next, see the row and the chain as real structures: arrays and dynamic arrays, then linked lists.

Keep going in Data Structures and Algorithms · 1 of 21

Next post
Arrays and Dynamic Arrays: Full? Get a Box Twice the Size
Community · Free to join
Single logo

StudyEasy AI Community

Hosted onSkool

Learn AI engineering, share what you build, and connect with other learners.

  • Free resources: lesson files, notebooks and code

  • Ask questions and join engineering discussions

  • Meet real people learning and building with AI

Join free on Skool

Related course on Udemy

Data Structures and Algorithms Concepts: No Coding Needed

How stacks, trees, hash tables, sorting and graphs really work, step by step, with pictures.View on Udemy ↗: Data Structures and Algorithms Concepts: No Coding Needed (paid course, opens in a new tab)

Related posts

Arrays and Dynamic Arrays: Full? Get a Box Twice the Size

A fixed array never gets longer. A dynamic array fills its box, then copies everything into a box twice the size. Build one for Emma's playlist in Python, count the copies and shifts, and see why adding at the end stays cheap while inserting at the front costs almost 50 million shifts for 10,000 songs.

Linked Lists: A Chain of Clues, Built in Python

In a linked list every node holds a value and the address of the next node. Build a treasure hunt chain in Python: a new first clue is two moves at any size, slipping a clue in or out is just changing next, but reaching clue number i is a walk of i hops.

Stacks: Last In, First Out, With the Undo Button

A stack is last in, first out: the newest thing you put on is the first thing you take off. Build Emma's undo button in Python from a list and one top index, push, pop and peek in one step each, undo after a million edits, and see what happens when you pop an empty stack.

Queues: First In, First Out, With a Ring of Cells

A queue is first in, first out: whoever joins the line first is served first. Build Kate's cinema ticket line in Python as a ring of four cells, where nobody steps forward and only head and tail move, serve a million people with the same four cells, then break it with a line that is already full.

On this page

  • Six songs on a phone
  • A wall of numbered lockers
  • Adding at the front
  • Same boxes, new arrangement
  • What happens when the list grows
  • Where this goes next
  • Recap
Community · Free to join
Single logo

StudyEasy AI Community

Hosted onSkool

Learn AI engineering, share what you build, and connect with other learners.

  • Free resources: lesson files, notebooks and code

  • Ask questions and join engineering discussions

  • Meet real people learning and building with AI

Join free on Skool

Related course on Udemy

Data Structures and Algorithms Concepts: No Coding Needed

How stacks, trees, hash tables, sorting and graphs really work, step by step, with pictures.View on Udemy ↗: Data Structures and Algorithms Concepts: No Coding Needed (paid course, opens in a new tab)

Single logo

Empowering Education, One Course at a Time

About
About usContact us
Legal
Terms of UsePrivacy Policy

© 2026 StudyEasy Organization. All rights reserved.