What data structures and algorithms are

A data structure is a way of organising information in a computer so it’s easy to use. An algorithm is a step-by-step method for solving a problem.

Think of a contacts list. You could write names in the order you met people, which makes adding someone easy, but finding “Tunde” means reading the whole list. Or you could keep them in alphabetical order, which makes finding someone fast, but adding someone means squeezing them into the right place. Neither way is best at everything. Each data structure is good at some jobs and slow at others, and choosing well is most of the skill.

The method you use to search the list is an algorithm. Reading every name one by one works, but for a million names it’s slow. Opening the alphabetical list in the middle and halving the search each time finds anyone in about 20 steps. That difference, between a method that takes days and one that takes a fraction of a second, is what this subject is about.

You’ll rarely build these from scratch at work, because languages provide them. But you’ll choose between them every day, and the choice decides whether your code is fast or painfully slow. They’re also what most coding interviews test.

What you’ll be able to do

By the end you will be able to:

  • estimate how a piece of code slows down as its input grows (called Big-O);
  • pick the right container for a job: list, dictionary, set, queue, heap and more;
  • explain how trees and graphs store things like folders, maps and social networks;
  • search and sort efficiently, and know why some methods are faster;
  • recognise common problem shapes and the standard technique for each;
  • solve coding interview problems with a clear, repeatable process.

Where to start

Need to learn to code first? Start with Programming Fundamentals; this course assumes you can read a short program.

Read in the order below. Inside each folder, the file numbers follow this order. The only jumps between folders are Big-O (Step 1) and recursion (Step 3), which live in the algorithms folder but come before the data structures that use them.

Step 1: Measuring how fast code is

  1. Loops and What They Cost: counting how many times code repeats, and spotting hidden loops that make code slow.
  2. Growth and Big-O notation: the shorthand everyone uses to describe how code slows down as the input grows. Everything after this uses it.

Step 2: The basic containers

  1. Arrays: items stored side by side, so you can jump straight to any position.
  2. Dynamic Arrays: arrays that grow when they’re full, like Python’s list.
  3. Hash Maps: finding a value by its name almost instantly, like Python’s dictionary.
  4. Linked Lists: items chained together, each pointing to the next.
  5. Stacks and Queues: last in, first out (a stack of plates) and first in, first out (a queue at the bank).

Step 3: Recursion

  1. Recursion: solving a problem by solving smaller copies of it. Trees and many algorithms depend on it.

Step 4: Trees

  1. Trees: information arranged in branches, like folders on a computer, including the search trees used for fast lookups.
  2. Tree Traversal: the standard ways to visit every item in a tree.
  3. Heaps: always getting the smallest (or largest) item quickly, as in a priority queue.
  4. Tries: trees for words, used for autocomplete.

Step 5: Graphs

  1. Graphs: things connected to other things, like roads between cities or friends on social media.
  2. Graph Traversal: exploring a graph, going deep first (DFS) or wide first (BFS).
  3. Graph Algorithms: shortest routes, putting tasks in a valid order, and connecting everything as cheaply as possible.
  4. Union-Find: quickly tracking which items belong to the same group.

Step 6: Classic algorithms

  1. Searching: looking through items one by one, and halving the search each time (binary search).
  2. Divide and Conquer: splitting a problem in half, solving each half, and combining the answers.
  3. Sorting: putting things in order, and why some methods are much faster than others. The fast ones are divide and conquer.
  4. Greedy Algorithms: taking the best-looking choice at each step, and when that’s safe.
  5. Dynamic Programming: remembering answers to smaller problems so you never solve the same one twice.

Step 7: Extra techniques (read as needed)

Practice

  • Question banks: every lesson has a matching -qb note: short questions with hidden answers, for testing yourself without looking. Start with Loops and What They Cost: question bank. The method is explained in the arrays bank.
  • Patterns: LeetCode Patterns covers 15 techniques that keep coming up in problems, such as two pointers and sliding window. Recognising which one a problem needs is most of the battle. Do these after Step 6.
  • Problems: NeetCode 150 has all 150 problems from a well-known practice list, each worked through and linked to the lesson behind it.
  • Interviews: DSA interview prep, and the interview playbook for a step-by-step process to use in a coding interview.

Key ideas to remember

  1. Every data structure makes some jobs fast by making others slow. There’s no structure that’s best at everything. → Arrays
  2. Ask which operation your code does most, then pick the structure that makes that one fast.
  3. Searching a list is slow; looking up a dictionary is fast. Swapping one for the other is often the biggest speed-up available. → Hash Maps
  4. A loop inside a loop usually means trouble at scale. A million items checked against a million items is a trillion steps. → Loops and What They Cost
  5. Halving the problem each step is enormously fast. A million items takes about 20 steps. → Searching

About this course

  • Size: about 40,000 words across 30 lesson notes, each with a question bank, plus about 50,000 words working through all 150 NeetCode problems.
  • Where it came from: written against a Codility course (its material is in dsa/pdfs/), then checked against the NeetCode 150 list to fill gaps. Several lessons (amortised analysis, recursion, dynamic programming, A*, and others) were added after a real interview showed they were missing; see the interview gap list.
  • How the files are organised: ways of storing data are in 02-data-structures/; methods are in 03-algorithms/, unless a method belongs to one structure, in which case it’s filed with that structure (so graph searching lives under 09-graphs/).
  • Renumbered in November 2026 so the files follow the reading order: stacks and queues now come before trees and graphs, and searching before sorting.
  • Not covered yet: fast text searching (the KMP algorithm), and segment and Fenwick trees.
↑ Back to Kingsley's Knowledge Base