Part VI: Algorithms and Data Structures
This is the heart of computer science.
Not Python. Not VS Code. Not even programming, exactly. The study of algorithms and data structures is the study of how to solve problems efficiently --- and that question predates computers by more than two thousand years. Euclid wrote down a step-by-step method for finding the greatest common divisor of two numbers around 300 BCE, and computers still use it today. When you learn to analyze whether your approach scales to a million records or collapses under its own weight, you are engaging with the deepest ideas the discipline has to offer.
What This Part Covers
Chapter 17: Algorithms and Problem-Solving Strategies introduces the tools for reasoning about efficiency. You will learn Big-O notation --- not as a formal mathematical proof, but as an intuitive framework for asking "what happens when the input gets ten times bigger?" You will compare brute force, greedy, and divide-and-conquer strategies, and you will learn to trace through algorithms by hand before writing a single line of code. This chapter changes how you evaluate your own solutions.
Chapter 18: Recursion introduces functions that call themselves --- an idea that is initially bewildering and eventually beautiful. You will learn to identify base cases and recursive cases, trace recursive calls through the call stack, and build solutions to problems that are naturally recursive: nested dictionaries, directory trees, deeply nested lists, and (in the case study) fractals. You will also learn when recursion is elegant and when it is a trap --- including how a naive recursive Fibonacci function grinds to a halt, and how memoization rescues it.
Chapter 19: Searching and Sorting applies your algorithmic thinking to the two most fundamental operations in computing. You will implement linear search, binary search, selection sort, insertion sort, and merge sort from scratch, compare their performance empirically and theoretically, and see why Python's built-in sorted(), which is built on Timsort (a hybrid of merge sort and insertion sort), will outperform anything you write in pure Python. More importantly, you will learn to choose the right tool for the situation.
Chapter 20: Stacks, Queues, and Beyond introduces abstract data types --- structures defined by what they do, not how they are implemented. You will build stacks (last in, first out) and queues (first in, first out), use them for undo systems, expression evaluation, and breadth-first traversal, and get a preview of linked lists, trees, graphs, and hash tables that will motivate your next computer science course.
Why This Matters
Algorithms and data structures are what interviewers ask about, what performance reviews measure, and what separates a developer who can build a prototype from one who can build a system that serves millions. When your database query takes thirty seconds instead of thirty milliseconds, the culprit is rarely the language or the hardware. Far more often it is the algorithm or the data structure. The thinking skills you develop in Part VI will remain valuable long after any specific language or framework has been replaced.
What You Will Be Able to Do
By the end of Part VI, you will be able to:
- Analyze algorithm efficiency using Big-O notation
- Apply problem-solving strategies: brute force, greedy, divide and conquer
- Write and trace recursive functions with confidence
- Implement and compare classic searching and sorting algorithms
- Build stacks and queues and apply them to real problems
- Choose appropriate data structures based on performance requirements
- Explain why algorithmic thinking matters beyond any single programming language
How the Chapters Connect
Chapter 17 gives you the analytical framework: Big-O, strategies, tracing. Chapter 18 adds recursion as a powerful problem-solving technique. Chapter 19 applies both to the concrete domain of searching and sorting, where you can measure and compare. Chapter 20 broadens the landscape, introducing the abstract data types that form the foundation of CS2 and beyond. Each chapter builds on the analytical habits established in the one before.
Your Progressive Project: TaskFlow
TaskFlow becomes a laboratory for algorithmic thinking. In Chapter 17, you will work out the Big-O cost of TaskFlow's core operations, optimize its search, and add a benchmark command to measure the difference (v1.6). In Chapter 18, you will implement recursive search through nested categories and subcategories (v1.7). In Chapter 19, you will add custom sorting --- by priority, due date, creation date, and alphabetically --- and implement binary search on sorted task lists (v1.8). In Chapter 20, you will build an undo/redo system using two stacks and a first-in, first-out queue for processing scheduled tasks in order (v1.9).
These are not toy exercises. Undo systems, task queues, and efficient search are features users expect in real applications. You are building them from first principles.