Data structures and algorithms flashcards
How to store data and solve problems fast, from arrays to graphs.
What are and , in plain words?
A is a way of arranging information so it is quick to use. An is a step-by-step recipe for solving a problem with that information.
Tap to turn over. Swipe right if you know it, left to see it again.
What you will learn
Start from zero
- What DSA is and why it matters3 cards
- Lists, indexes and functions2 cards
- Stacks, queues, hash maps and sets2 cards
- Speed, searching and recursion3 cards
- Getting ready2 cards
Core basics
- Why structures matter2 cards
- Big O and complexity4 cards
- Arrays and linked lists2 cards
- Stacks and queues2 cards
- Hash maps and sets3 cards
- Searching2 cards
- Recursion2 cards
- Strings and problem-solving method2 cards
Next steps
- Sorting4 cards
- Trees and binary search trees3 cards
- Heaps and priority queues2 cards
- Graphs, grids and traversal5 cards
- Array patterns: pointers, windows, intervals, prefix sums4 cards
- Linked list techniques2 cards
- Practical optimisation and bit tricks2 cards
Go deeper
- Dynamic programming4 cards
- Greedy and backtracking2 cards
- Shortest paths, ordering and spanning trees4 cards
- Advanced data structures5 cards
- Amortised cost, recurrences and hash attacks3 cards
- Advanced search patterns3 cards
Final test and certificate
10 questions drawn fresh from the whole topic, about 15 minutes. Sign in, score 80% or more and get a free certificate with your name and a public check link anyone can open, such as an employer or a teacher. Not signed in? Try a practice test from the cards.
Take the final testAbout these cards
- Reviewed 26 October 2026
- CoversPython 3.14 and 3.15Language-independent algorithms (CLRS-style analysis)
Checked against
Data structures and algorithms at a glance
Data structures are ways to arrange information, and algorithms are step-by-step recipes that use them to solve problems fast.
Like a kitchen: shelves and jars keep things easy to find, and a recipe tells you the steps to cook.
Words you will meet
- Data structure
- A way of arranging information so it is quick to use
- Algorithm
- A step-by-step recipe for solving a problem
- Index
- The number of a box in a list, counting from 0
- Big O
- A rough way to say how the work grows when the data grows
- Stack
- A pile where the last thing in is the first thing out
- Queue
- A line where the first thing in is the first thing out
- Hash map
- A store of key and value pairs that finds a value straight from its key
- Recursion
- A function that solves a problem by calling itself on a smaller piece
The steps
- 1. Start from zero (12 cards): What data structures and algorithms are, where you meet them, and the plain words the core basics use.
- 2. Core basics (19 cards): Big O, arrays, lists, stacks, queues, hash maps, sets, searching and recursion.
- 3. Next steps (22 cards): Sorting, trees, heaps, graphs, BFS and DFS, two pointers, sliding windows and indexes.
- 4. Go deeper (21 cards): Dynamic programming, greedy proofs, backtracking, shortest paths, union-find, tries and amortised cost.
All 12 cards in Start from zero
- What are data structures and algorithms, in plain words?
- A data structure is a way of arranging information so it is quick to use. An algorithm is a step-by-step recipe for solving a problem with that information.
- What goes wrong when a program ignores them?
- It works with ten items but crawls with a million. Checking every name one by one is fine for a class list and hopeless for a whole country.
- Where do you meet these ideas in daily life?
- A queue at the ticket counter, a stack of plates, a phone book in name order, a lift that stops at the nearest floor first. Each is a way to arrange things or a rule for handling them.
- In Python, what are a list and an index?
- A list is a row of numbered boxes in the computer's memory, its short-term workspace. The index is a box's number, and it starts at 0, so
orders[0]is the first box. - What do input, output and function mean?
- A function is a named set of steps. You give it input (the data to work on), and it gives back output (the answer), like a juicer taking fruit and giving juice.
- What are a stack and a queue?
- A stack is like a pile of plates: the last one in is the first one out. A queue is like a ticket line: the first one in is the first one out.
- What are a hash map and a set?
- A hash map stores pairs: a key and its value, like a coat check where your ticket (the key) gets your coat at once. A set is a bag of items with no repeats.
- What do "n" and Big O mean?
- n is how many items you have. Big O is a rough way to say how the work grows as n grows: O(1) stays the same, O(n) grows with the items, O(log n) grows very slowly.
- What is the difference between linear search and binary search?
- Linear search checks items one by one. Binary search works on sorted items: look in the middle, throw away the half that cannot hold it, and repeat.
- What is recursion?
- Recursion is a function that solves a problem by calling itself on a smaller piece. It needs a base case: the smallest piece, answered directly, so it knows when to stop.
- What do you need before starting?
- Basic Python (variables,
ifand loops) and a computer with Python 3, or any online Python editor in your browser. Paper and a pencil help to trace steps. - What will you be able to do after this topic?
- Pick the right structure for a job, guess how fast code will be as data grows, and solve classic problems like searching, matching pairs and checking brackets.
Data structures and algorithms cheatsheet
Big O, fast to slow
O(1)Hash lookup, array indexO(log n)Binary search, balanced tree, heap pushO(n)One pass, linear searchO(n log n)Good sorting, n heap operationsO(n^2)Nested loops over the same dataO(2^n) / O(n!)All subsets / all orderings~10^8 simple steps/sCompiled code; Python is ~10 to 50x slower
Data structure costs
list: index O(1), append O(1)*, insert(0) O(n)Dynamic array (* amortised)deque: append/popleft O(1)Queue or stack at both endsdict/set: get, add, in O(1) avgHash table, O(n) worstheapq: push/pop O(log n), peek O(1)Priority queuebalanced BST / B-tree: O(log n)Ordered keys, range scanstrie: O(length of key)Prefix searchunion-find: ~O(1)Group membership and merging
Python helpers
collections.dequeQueue, BFScollections.Counter / defaultdictCounting / groupingheapq.heappush / nlargest(k, xs)Heap / top kheapq.heappush_max (3.14+)Built-in max-heap functionsbisect.bisect_left / insortBinary search in a sorted listfunctools.cacheMemoisationitertools.accumulatePrefix sumssorted(xs, key=...)Stable Timsort, O(n log n)
Pattern to use
Sorted array, find pair or rangeTwo pointers or binary searchLongest or shortest subarray with a ruleSliding windowSeen it before? Complement?Hash map or setTop k or next smallestHeapFewest steps, unweightedBFSAll combinations, constraintsBacktracking with pruningBest or count with overlapping subproblemsDynamic programmingNext greater or smaller elementMonotonic stackConnected groups, mergingUnion-find
Graph algorithms
BFS / DFSO(V + E) traversalDijkstra (heap)O((V + E) log V), weights >= 0Bellman-FordO(V x E), negative edges, cycle checkTopological sort (Kahn)O(V + E), DAG orderingKruskal / PrimMinimum spanning treeThree-colour DFSCycle detection in directed graphs