6.006 | Spring 2008 | Undergraduate
Introduction to Algorithms


These recitation slides are courtesy of Victor Costan, one of the course TAs, and are used with permission.

Introduction and document distance
R1 Document distance in Python (docdist{1,2,3,4}.py) (PDF)  
R2 Python cost model, review for asymptotic notation and mergesort (PDF)

Zipped data (numbers) (ZIP) (This zip file includes: 2 .jpg files, 1 .gz file, 1 .tiff file, 1 .numbers file, and 1 .pkginfo file.)

Python Cost Model

Binary search trees
R3 Binary search trees (PDF) Code for binary search trees augmented with subtree size (PY)
R4 AVL Trees (balanced binary search trees) (PDF) Code for AVL trees (uses the BST code from R3) (PY)
R5 Hashing in Python, mutability (PDF) The dangers of mutable dictionary keys (PY)
R6 Karp-Rabin review, rolling hashes principles and code (PDF) Rolling hash code (PY)

Open addressing: theory review, Python code

More rolling hashes (PDF)

Open addressing code (PY)

Overview of sorting methods

Heaps as data structures: principles, sorting, priority queues (PDF)

R9 Quiz review: interesting problems (PDF)  
R10 Counting, radix and bucket sorting, gas simulation  
R11 Breadth-first search and depth-first search (PDF)

Code for breadth-first search (PY)

Code for depth-first search (PY)

Shortest paths
R12 Assistance for problem set (PDF)  

Generic shortest-path algorithm: concepts, properties

Bellman-Ford: examples, negative-cost cycles


Hands-on Dijkstra: pseudocode, preconditions, examples, why it works

Priority queues: review, extended Python implementation (PDF)

R15 Array implementation of Dijkstra  
Dynamic programming
R16 Hands-on dynamic programming: big ideas, memoization in Fibonacci, crazy cards, Dijkstra and Bellman-Ford algorithm as dynamic programming (PDF)  
R17 More dynamic programming: beating Super Mario Brothers, getting points back on tests (LCS), Crazy Eights (PDF)  
R18 Even more dynamic programming: maximum-sum sub-array, more Tetris (PDF)  
R19 Knapsack and its variants, structural dynamic programming: covering a tree with templates, dominating set  
R20 Dynamic programming practice: live Python coding, dominating sets, structural dynamic programming: covering a tree with templates

Live Python Coding problems (problem statement, tests, and solutions are included):

- Matrix chain multiplication (ZIP) (This zip file includes: 3 .py files, 1 .pyc file, 1 .rb file, and 6 data files.)

- Longest zig-zag subsequence (ZIP) (This zip file includes: 3 .py files, 1 .pyc file, 1 .rb file, and 4 data files.)

R21 Divide and conquer vs. dynamic programming on problems: matrix multiplication, tower, max-sum subarray, closest pair  
R22 Numerics review, Strassen’s algorithm for matrix multiplication Strassen’s algorithm for fast matrix multiplication is covered in CRLS, chapter 28, pp. 735-742.
Beyond 6.006
R23 Review for the final exam (PDF)  
Learning Resource Types
assignment Problem Sets
grading Exams with Solutions
notes Lecture Notes
assignment_turned_in Presentation Assignments with Examples