Data Structures & Algorithms
Measure efficiency with Big-O, then use searching, sorting, hash maps, stacks, linked lists, trees, graphs and dynamic programming in Python.
Leads to: Data Scientist, Machine Learning Engineer, Software Developer, Mobile Developer, Back-End Developer, QA / Test Engineer, Data Engineer, Computer Science Teacher
Before you start
This course builds on Python Fundamentals. Take it first if you are new to the topic.
About this course
An intermediate course for learners who can already write basic Python and want to write code that stays fast as data grows. You will learn to describe an algorithm's cost with Big-O, implement linear and binary search and two classic sorts, and choose between lists, dicts, sets, stacks, queues and linked lists. You will then write recursive functions, traverse trees and binary search trees, and explore graphs and grids with depth-first and breadth-first search. The last module covers the two-pointer and sliding-window patterns, an introduction to dynamic programming, and a repeatable framework for solving problems out loud, as you would in a technical interview or a pair-programming session. Every lesson has a reading, free videos, a quiz and a Python exercise checked automatically on normal and edge-case inputs. Prerequisite: Python Fundamentals.
Course content
Module 1
Thinking About Efficiency
3 lessons · 1h 29mDescribe how code slows as data grows with Big-O notation, then implement linear and binary search, insertion sort and merge sort.
- 30mBig-O notationReading
Describe how an algorithm's work grows with its input, and compare O(1), O(log n), O(n) and O(n^2) code.
- 28mLinear and binary searchReading
Search an unsorted list step by step, then halve a sorted list each time with binary search.
- 31mSorting algorithmsReading
Implement insertion sort and merge sort, and see why one is O(n^2) and the other O(n log n).
Module 2
Core Structures
3 lessons · 2h 14mChoose the right container: lists and hash maps for lookups and counting, stacks and queues for order, and linked lists for pointer-based data.
- 43mArrays and hash mapsReading
Know what lists and dicts are fast and slow at, and use a dict to count things and solve two-sum in one pass.
- 41mStacks and queuesReading
Use a stack (last in, first out) to check brackets, and a deque as a queue (first in, first out).
- 50mLinked listsReading
Build a singly linked list from nodes, walk it, and reverse it in place by re-pointing links.
Module 3
Trees and Graphs
3 lessons · 1h 36mWrite recursive functions, traverse binary trees and binary search trees, and explore graphs and grids with depth-first and breadth-first search.
- 40mRecursionReading
Write functions that call themselves on a smaller input, with a base case that stops them.
- 31mTrees and BSTsReading
Represent a binary tree with nodes, traverse it in pre-, in- and post-order, and insert into a binary search tree.
- 25mGraphs, BFS, and DFSReading
Represent a graph as an adjacency list, explore it with depth-first search, and find shortest paths in a grid with breadth-first search.
Module 4
Problem Solving
3 lessons · 2h 18mApply the two-pointer and sliding-window patterns, speed up recursion with dynamic programming, and practise solving problems out loud.
- 32mCommon patternsReading
Recognise two-pointer and sliding-window problems and turn O(n^2) pair and subarray searches into one pass.
- 36mIntro to dynamic programmingReading
Speed up recursive solutions by remembering answers to sub-problems (memoisation), then build them bottom-up in a table.
- 1h 10mSolving problems out loudReading
Use a repeatable framework to understand, plan, code, test and explain a problem while talking through your thinking.