Python Quest

Learning map · Track 16 · advanced

Algorithms and Problem Solving

Knowing Python is not the same as knowing what to write. When a task is new — find the cheapest delivery route, spot duplicate customer records in a hundred thousand rows, schedule as many meetings as possible into one room — you need a way to get from the problem to a program that is correct and fast enough. This track teaches that way of working: understand the problem through examples, break it into steps, write a plan, implement it, and test it on the cases that break careless code. Along the way you meet the classic tools that experienced programmers reach for: binary search, sorting, recursion, hash-based lookups, stacks and queues, two pointers and sliding windows, greedy choices, dynamic programming and graph search.

It is written for learners who are comfortable with functions, collections, classes and modules. The focus is practical reasoning about cost: counting the work a program does, recognising O(n), O(n log n) and O(n²) growth, and knowing when a dictionary or a set turns a slow program into a fast one. Several exercises are graded for speed as well as correctness — a solution that compares every pair of items will give the right answer but fail the time limit, exactly as it would on real data. The track ends with a small route and schedule planner for a delivery business, built milestone by milestone, so you practise choosing an approach rather than recalling one.

By the end of this track you can

  • Work through an unfamiliar problem methodically: restate it, collect examples and edge cases, write pseudocode, implement and test
  • Estimate the cost of an algorithm with Big-O reasoning and recognise accidentally quadratic code before it reaches real data
  • Search and sort efficiently with binary search, bisect, merge sort and sorted() with stable keys
  • Use dictionaries, sets, stacks, queues and heaps to make common tasks fast: deduplication, grouping, pair finding, scheduling and top-k
  • Apply recursion, memoisation, greedy choices and dynamic programming, and explain when a greedy shortcut gives the wrong answer
  • Model connections as graphs and find shortest routes and connected groups with breadth-first and depth-first search

Lessons

  1. 1A process for solving problemsTurn an unfamiliar task into working code by restating it, collecting examples, planning in pseudocode, implementing, testing and reflecting.35 min · 3 exFree
  2. 2Linear and binary searchFind items by checking each one in turn, or by halving a sorted list again and again, and use the bisect module for sorted data.45 min · 4 exMembers
  3. 3Measuring the cost of codeCount the work an algorithm does, describe how it grows with Big-O, and time code honestly.45 min · 4 exMembers
  4. 4Sorting algorithmsUnderstand how selection, insertion and merge sort work and what they cost, then use sorted() with stable keys in practice.50 min · 4 exMembers
  5. 5Recursion in depthSolve problems by reducing them to smaller copies of themselves, split work with divide and conquer, and remove repeated work with memoisation.50 min · 4 exMembers
  6. 6Hashing for speedUse dictionaries and sets to replace repeated searching with constant-time lookups: find repeats, pairs, groups and duplicates in one pass.45 min · 4 exMembers
  7. 7Stacks and queuesUse a list as a stack and collections.deque as a queue to match brackets, undo edits, serve jobs in order and explore step by step.45 min · 4 exMembers
  8. 8Two pointers and sliding windowsWalk through sequences with two indexes instead of nested loops: find pairs in sorted data and compute running windows such as moving averages and longest streaks in O(n).50 min · 4 exMembers
  9. 9Greedy algorithmsBuild a solution one locally best choice at a time — making change, scheduling bookings, packing tasks — and learn to recognise when greedy gives the wrong answer.45 min · 4 exMembers
  10. 10Dynamic programmingSolve problems built from overlapping subproblems by computing each subproblem once — top-down with a memo or bottom-up with a table.55 min · 4 exMembers
  11. 11Graphs: routes, networks and hierarchiesRepresent connections as adjacency lists, find shortest routes with breadth-first search, and explore networks and org charts with depth-first search.55 min · 4 exMembers
  12. 12Choosing an approach: a delivery plannerWeigh readability, speed and memory when choosing an algorithm, use heapq for top-k and priority queues, and build a route and schedule planner milestone by milestone.90 min · 6 exMembers