Recursion and data structures
Thinking recursively, avoiding repeated work, and building the classic structures that the rest of computer science is made of.
About 9 hours of study
Learning objectives
- Solve problems recursively
- Speed up recursion with memoization
- Use stacks and queues
- Build linked lists and trees from nodes
Lessons
- 1
Recursion in practice Intermediate
Recursive sums, fast powers and the Tower of Hanoi, with every call visible on the stack.
- 2
Memoization Intermediate
Remember answers you have already computed, and turn slow recursion into fast recursion.
- 3
Stacks and queues Intermediate
Last in, first out and first in, first out: two ways to line up work, and where each is used.
- 4
Linked lists Intermediate
Chain objects together with references, walk the chain, insert in the middle, and reverse it.
- 5
Binary trees Intermediate
Build trees of nodes with left and right children, and solve tree problems with recursion.
Module practice
- Recursive sumEasy
- Tower of HanoiMedium
- Every arrangement of a wordHard
- Fast FibonacciEasy
- Climbing stairsMedium
- The fewest coinsHard
- Reverse with a stackEasy
- Balanced bracketsMedium
- Serving a queueMedium
- A postfix calculatorHard
- Length of a linked listEasy
- Reverse a linked listMedium
- Remove a value from a linked listHard
- Count the leavesEasy
- Binary search treeMedium
- A tree level by levelHard