Study
All courses
CSC-401 Computer Science · 400 level

Algorithms and Complexity Analysis

Measuring what a program costs before you run it

10 units · 38 lessons · about 12 hours of reading

Start the course First: Definition of an Algorithm

The route

Lessons are in the order that makes each one easier than the last. Each unit ends with a short quiz.

  1. 0/4
    Unit 1

    Foundations of Algorithm Analysis

    Algorithms, how their cost is measured independently of any machine, and the notation used to compare growth rates.
    1. Definition of an AlgorithmFree A finite, unambiguous recipe that always produces the right answer, and the awkward questions that definition raises. 17 min
    2. Input Size and the Basic Operation You cannot measure speed in seconds, so measure something else and count it. 18 min
    3. Orders of Growth and Asymptotic Notation Three symbols, four quantifiers each, and the reason a factor of a thousand does not matter. 20 min
    4. Analysing Non-Recursive Algorithms A loop is a sum, a nested loop is a product, and the rest is arithmetic. 18 min
    5. Unit 1 quiz8 questions on this unit 10 min
  2. 0/4
    Unit 2 Full plan

    Analysis of Recursive Algorithms

    Recurrences, backward substitution, the master theorem and the closed forms of linear recurrences.
    1. Recurrences from Recursive Code A recursive function's cost is an equation containing the function itself, and reading it off the code is a four-step recipe ending in an initial condition. 17 min
    2. Solving Recurrences by Backward Substitution Substitute, substitute again, notice the pattern, and put it back together. 18 min
    3. The Master Theorem Three cases, one comparison, and the answer to most divide-and-conquer recurrences without algebra. 19 min
    4. Linear Recurrences and Closed Forms A linear recurrence a·X(n) + b·X(n−1) + c·X(n−2) = 0 is solved by the roots of a·r² + b·r + c = 0, which give a closed form valid for every n. 18 min
    5. Unit 2 quiz8 questions on this unit 10 min
  3. 0/4
    Unit 3 Full plan

    Brute Force and Exhaustive Search

    The straightforward approach, and the point at which straightforward becomes impossible.
    1. Selection Sort and Bubble Sort Two simple sorts, one honest lesson about what simplicity costs. 17 min
    2. Sequential Search and Brute-Force String Matching Two algorithms with the same shape, one of which has a best case worth knowing. 18 min
    3. Exhaustive Search Try every possibility, and discover exactly where every possibility stops being a plan. 19 min
    4. Graph Traversal — Depth-First and Breadth-First Two ways to visit every vertex, and the applications that follow from each. 19 min
    5. Unit 3 quiz8 questions on this unit 10 min
  4. 0/4
    Unit 4 Full plan

    Decrease and Conquer

    Shrinking the problem by one, by half, or by a variable amount, and the algorithms that follow.
    1. Insertion Sort One element at a time, into a sorted prefix that is always correct. 16 min
    2. Topological Sorting Ordering a set of tasks so that every prerequisite comes first. 17 min
    3. Binary Search and the Fake-Coin Problem Halving the problem, and what happens when the halving has to be discovered. 18 min
    4. Generating Subsets and Permutations Enumerating combinatorial objects, one reduction at a time. 18 min
    5. Unit 4 quiz8 questions on this unit 10 min
  5. 0/4
    Unit 5 Full plan

    Divide and Conquer

    Split the problem into independent parts, solve them recursively, and combine the answers.
    1. Mergesort Split, sort, and put back together in linear time. 17 min
    2. Quicksort Partition first, sort later, and let the pivot decide the cost. 18 min
    3. Integer Multiplication and Strassen's Matrix Multiplication Regrouping one multiplication into three smaller ones, and Strassen's seven matrix products instead of eight, both buy a smaller exponent than the obvious algorithm's. 19 min
    4. Tree Traversals and the Closest-Pair Problem Splitting a tree at its root, and splitting a plane at its median line. 19 min
    5. Unit 5 quiz8 questions on this unit 10 min
  6. 0/3
    Unit 6 Full plan

    Transform and Conquer

    Change the problem into one that is easier to solve, then solve that one.
    1. Presorting Pay once for order, and let every later question be easier. 16 min
    2. Gaussian Elimination Transforming a system of equations into one that solves itself. 19 min
    3. Heaps and Heapsort Turning an array into a tree without moving anything. 19 min
    4. Unit 6 quiz6 questions on this unit 8 min
  7. 0/4
    Unit 7 Full plan

    Space and Time Trade-offs

    Buying speed with memory — counting, hashing, binary search trees and shift tables.
    1. Counting Sort and Input Enhancement Trading a table for a loop, and beating n log n by knowing the keys. 18 min
    2. Hashing Turning a key into an address, and paying for collisions. 19 min
    3. Binary Search Trees Order maintained for free, and the shape that decides the cost. 19 min
    4. Horspool and Boyer–Moore String Matching Precompute a shift table, and never look at most characters at all. 18 min
    5. Unit 7 quiz8 questions on this unit 10 min
  8. 0/4
    Unit 8 Full plan

    The Greedy Technique

    Take the best thing available now, and know exactly when that is safe.
    1. Prim's Algorithm Grow one tree by always taking the cheapest edge out of it. 17 min
    2. Kruskal's Algorithm and Union–Find Sort the edges, take what does not close a loop, and know fast whether it does. 18 min
    3. Dijkstra's Algorithm Greedy shortest paths, and the assumption that makes it correct. 19 min
    4. Huffman Coding and the Limits of Greedy Choice A greedy algorithm that compresses files, and two that cannot count coins. 19 min
    5. Unit 8 quiz8 questions on this unit 10 min
  9. 0/4
    Unit 9 Full plan

    Dynamic Programming

    Remember the answers to subproblems, and pay for each one only once.
    1. Overlapping Subproblems and Dynamic Programming Remember the answer once, and never compute it twice. 18 min
    2. The Coin-Row and Coin-Collecting Problems Two two-dimensional intuitions, and the index that makes them recurrences. 19 min
    3. The Knapsack Problem One table, two capacities, and a decision that a greedy rule cannot make. 19 min
    4. Warshall's and Floyd's Algorithms All pairs at once, by allowing one intermediate vertex at a time. 19 min
    5. Unit 9 quiz8 questions on this unit 10 min
  10. 0/3
    Unit 10 Full plan

    Limits of Algorithmic Power

    What P and NP mean, which problems are NP-complete, and what to do when no efficient algorithm is known.
    1. Decision Problems, P and NP P holds the problems solvable in polynomial time and NP the ones whose answers can be checked in polynomial time; the gap between them is the open question. 19 min
    2. Reductions and NP-Complete Problems Proving a problem hard by showing it can express another. 19 min
    3. Approximation, Backtracking and Branch and Bound An approximation ratio, backtracking's pruning rule and branch-and-bound's optimistic bound are the three ways to finish a hard instance instead of solving it exactly. 20 min
    4. Unit 10 quiz6 questions on this unit 8 min

Practise and remember