Trees and Graphs
Official syllabus text (word for word)
Trees and Graphs — Trees: Representation Of Trees; Binary Trees - Types and Properties, Binary Tree Representation, Tree Operations, Tree Traversals; Expression Trees; Binary Search Trees - Binary Search Tree Operations; Binary Heaps - Binary Heap Operations, Priority Queue. Graphs: Definitions; Representation of Graphs; Depth First Search and Breadth First Search; Applications of Graphs - Single Source All Destination.
- 1Trees: terminology and representation
Tree vocabulary (root, leaf, degree, level, height…) and three ways to store a general tree.
lesson live - 2Binary trees: types and properties
At most two children per node: full, complete, skewed trees and the formulas that come up every year.
lesson liveasked 1× - 3Binary tree representation
Store a binary tree in an array (children at 2i and 2i + 1) or with linked nodes — and convert between drawing and array.
lesson livevisualizerC codeasked 2× - 4Tree operations and traversals
Inorder, preorder, postorder and level order — four ways to visit every node, with recursive algorithms.
lesson livevisualizerC codeasked 2× - 5Expression trees
Operators inside, operands at the leaves: build the tree for any expression and read off prefix, infix and postfix.
lesson livevisualizerC codeasked 2× - 6Binary search trees
Left smaller, right bigger: search, insert and the three delete cases — with the KTU questions worked out.
lesson livevisualizerC codeasked 3× - 7Binary heaps and priority queues
A complete binary tree with the biggest (or smallest) key on top — the engine behind priority queues and heap sort.
lesson livevisualizerC codeasked 4× - 8Graph definitions
Vertices, edges and the vocabulary — directed, undirected, degree, path, cycle, connected, weighted.
lesson live - 9Graph representation
Adjacency matrix vs adjacency list — how to store a graph and when to choose which.
lesson livevisualizerC codeasked 1× - 10Depth-first and breadth-first search
Explore a graph level by level with a queue (BFS) or go as deep as possible with a stack or recursion (DFS).
lesson livevisualizerC codeasked 3× - 11Single source all destinations (Dijkstra)
Dijkstra's algorithm: the shortest distance from one source to every vertex, with a step-by-step table.
lesson livevisualizerC codeasked 2×