A tree is a structure of nodes where each node points to its children, starting from a single root. Unlike arrays and linked lists, a tree is not a straight line, so it models things that branch: file systems, the page structure of a website, organization charts and decision processes. Most tree problems are solved with recursion, which makes this a natural follow-on from the previous modules.
This module starts with binary trees and their traversals: inorder, preorder and postorder, three ways of visiting every node. It then adds an ordering rule to get the binary search tree, where search, insert and delete take O(log n) when the tree is balanced, but can slow down to O(n) when it is not. Deleting a node is the trickiest operation, so it gets a lesson of its own.
The last lesson covers the trie, or prefix tree, which stores words letter by letter so that prefix searches and autocomplete are fast. Watch the lessons in order, then continue on to Heaps & Priority Queues.
Inorder, preorder and postorder traversals of a binary tree, explained with clear visuals so you can see the order each node is visited.
How a BST gives O(log n) search, insert and delete, when it degrades to O(n), and how balancing fixes it.
An animated walkthrough of the delete operation in a BST, the hardest of the three, since insertion and search are comparatively straightforward.
A beginner-friendly guide to the trie (prefix tree): how it works and why it handles prefix searches faster than a hash table.