Searching, sorting, linked lists, stacks, queues, hash tables, trees, heaps, graphs, backtracking and dynamic programming, in Python. Watch every comparison, swap, pointer and recursive call as it happens: the visual way to prepare for coding interviews.
Python · intermediate · 25 lessons · 3 h 6 min · free
What you'll learn
Reason about cost with Big O, from O(log n) to O(n²)
See every swap in bubble, selection, insertion, merge and quick sort
Build linked lists, stacks, queues, hash tables, trees and heaps yourself
Trace BFS, DFS and Dijkstra step by step
Solve interview classics: two pointers, sliding window, two sum, backtracking and dynamic programming
Before you start
Python Fundamentals
Lessons
Complexity and Searching
Big O, linear and binary search, two pointers and sliding windows.
Big O: Counting the Work: Count how many steps a single loop and a nested loop take for the same list. One grows with n, the other with n × n.
Linear Search: Check every item in turn until you find the target, or reach the end.
Binary Search: In a sorted list, look at the middle and throw away the half that cannot contain the target. Ten items take only three checks.
Two Pointers: Find two numbers that add up to a target in a sorted list, with one pointer at each end moving towards the other.
Sliding Window: Find the biggest sum of 3 numbers in a row by sliding a window along: add the new number, drop the old one.
Sorting
Bubble, selection, insertion, merge and quick sort.
Bubble Sort: Compare neighbours and swap them when they are out of order. After each pass the biggest unsorted value has bubbled to the end.
Selection Sort: Find the smallest remaining value and swap it into the next place. One swap per pass.
Insertion Sort: Take the next value and slide it left into its place among the already sorted ones, like sorting cards in your hand.
Merge Sort: Split the list in half until each piece has one item, then merge the sorted pieces back together. Divide and conquer.
Quick Sort: Pick a pivot, split the rest into smaller and larger, and sort each side the same way.
Lists, Stacks, Queues and Hashing
Linked lists, stacks, queues and hash tables.
Linked Lists: Chain nodes together with next pointers, add to the front in O(1), and walk the chain from head to the end.
Reversing a Linked List: The classic interview question: turn 1 → 2 → 3 into 3 → 2 → 1 by flipping each arrow, with three pointers.
Stacks: Balanced Brackets: Push every opening bracket, and pop when a closing one arrives. A stack checks nesting perfectly.
Queues: First in, first out: people join at the back and are served from the front. A deque does both ends in O(1).
How a Hash Table Works: Build a tiny dictionary: a hash function picks a bucket for each key. "cat" and "act" land in the same bucket: a collision.
Two Sum with a Hash Map: Find two numbers that add up to the target in one pass, by remembering what you have seen in a dictionary.
Trees and Heaps
Traversals, binary search trees and priority queues.
Tree Traversal: Visit every node of a binary tree in order: left subtree, the node, right subtree. Recursion does the bookkeeping.
Binary Search Trees: Insert keys so that smaller ones go left and bigger ones go right, then find a key by walking down one path.
Heaps and Priority Queues: Push tasks with priorities and always get the most urgent one first, using Python's heapq.
Graphs
Breadth-first search, depth-first search and shortest paths.
Breadth-First Search: Explore a graph level by level with a queue of paths, and find the shortest route from A to E.
Depth-First Search: Go as deep as you can along one path before backing up. Recursion keeps track of where to come back to.
Dijkstra's Shortest Paths: Find the cheapest route to every node in a weighted graph, always expanding the closest node next with a heap.
Backtracking and Dynamic Programming
Exploring every choice, and reusing answers to subproblems.
Backtracking: All Subsets: For each item, try including it, then try leaving it out. Undo each choice on the way back. The result is every subset.
Dynamic Programming: Memo and Table: Fibonacci without the waste: remember answers in a dict (top down), or fill a table from the bottom up.
Dynamic Programming: Coin Change: The fewest coins that make 6 with coins 1, 3 and 4. Greedy says 4 + 1 + 1; dynamic programming finds 3 + 3.
Related courses
Core Java Fundamentals: Learn Java from the ground up: how the JVM runs your code, data types, operators, conditionals, loops, methods, arrays, strings, object-oriented programming and exceptions. Every lesson traces a real program line by line. (44 lessons, 10 h 11 min)
Advanced Java: Collections, Generics and More: The Java you need beyond the basics: lists, stacks, queues, maps and sets, iterators, generics, ordering, equals and hashCode, enums, nested classes, immutability and resources. Every lesson traces a real program line by line. (14 lessons, 1 h 41 min)
Modern Java 8+ Features: Lambdas, functional interfaces, streams, Optional and the date-time API from Java 8, plus var, records and modern switch from later versions. Every lesson traces a real program line by line. (13 lessons, 1 h 35 min)
Java Interview Questions: Classic Java interview programs, traced line by line with the reasoning behind each step. (4 lessons, 1 h 10 min)