Algorithms I
Designing and analyzing algorithms: the RAM model and worst-case analysis, asymptotic notation and the limit test, summations, recurrences and the master theorem, insertion sort, merge sort and inversions, randomized quicksort, heaps and heapsort, the comparison-sorting lower bound with counting and radix sort, quickselect, median of medians, closest pair and Karatsuba multiplication, graph representations, breadth-first and depth-first search, cycle detection, topological sorting and strongly connected components, Dijkstra, Bellman-Ford and DAG shortest paths, minimum spanning trees with union-find, greedy algorithms with exchange arguments and Huffman coding, and a capstone on amortized analysis and algorithm design for a real problem.
CMPUT-204 Year 2 3 credits 12 lessons · 5 h 31 min
Offered by HSM University · Computing Science
What you'll learn
- Define algorithms, problem instances and input size, analyze algorithms in the RAM model by counting basic operations, distinguish best, worst and average cases, and use doubling experiments to check predicted growth.
- Prove and disprove asymptotic bounds using big-O, big-Omega, big-Theta, little-o and the limit test, order common functions by growth, and combine bounds for sequential and nested code.
- Analyze loops with summations, write recurrences for recursive algorithms, and solve them with recursion trees, substitution and the master theorem, recognizing when the master theorem does not apply.
- Implement and analyze selection sort, insertion sort and merge sort, relate insertion sort to inversions, prove merge sort correct by induction, and count inversions in Θ(n log n).
- Implement quicksort with random pivots, binary heaps and heapsort, build a heap in linear time, prove the Ω(n log n) lower bound for comparison sorting with decision trees, and apply counting and radix sort.
- Design divide-and-conquer algorithms for selection, the closest pair of points and integer multiplication, and analyze them with recurrences, including recurrences with unequal subproblems.
- Represent graphs with adjacency lists and matrices, choose between them, and implement breadth-first and depth-first search to find unweighted shortest paths, components and bipartitions in Θ(n + m).
- Classify edges in depth-first search, detect cycles, compute topological orders by DFS finish times and by Kahn's algorithm, and find strongly connected components with Kosaraju's algorithm.
- Solve single-source shortest-path problems with Dijkstra's algorithm, Bellman–Ford and DAG relaxation, justify each algorithm's correctness and restrictions, and detect negative cycles.
- Prove the cut and cycle properties, implement union–find with union by rank and path compression, and find minimum spanning trees with Kruskal's and Prim's algorithms.
- Design greedy algorithms for activity selection, interval partitioning, scheduling with deadlines and Huffman coding, prove them with greedy-stays-ahead and exchange arguments, and recognize problems where greedy fails.
- Apply amortized analysis, map real requirements to classic algorithmic problems, estimate costs before implementation, recognize NP-hard problems, and weigh constant factors and hardware effects in algorithm choice.
Course content
12 lessons · 5 h 31 min total · final exam
- 1 What algorithms are and how we analyze them 29 min · quiz
- 2 Asymptotic notation 30 min · quiz
- 3 Analyzing iterative and recursive algorithms 30 min · quiz
- 4 Sorting I: elementary sorts and merge sort 26 min · quiz
- 5 Sorting II: quicksort, heapsort and lower bounds 27 min · quiz
- 6 Divide and conquer beyond sorting 28 min · quiz
- 7 Graphs and graph search 26 min · quiz
- 8 Depth-first search applications 27 min · quiz
- 9 Shortest paths 27 min · quiz
- 10 Minimum spanning trees and union–find 30 min · quiz
- 11 Greedy algorithms 25 min · quiz
- 12 Capstone: designing and analyzing algorithms for a real problem 25 min · quiz
- E Final exam 20 questions
Requirements
Recommended background. You can start any course at any time.
Description
Designing and analyzing algorithms: the RAM model and worst-case analysis, asymptotic notation and the limit test, summations, recurrences and the master theorem, insertion sort, merge sort and inversions, randomized quicksort, heaps and heapsort, the comparison-sorting lower bound with counting and radix sort, quickselect, median of medians, closest pair and Karatsuba multiplication, graph representations, breadth-first and depth-first search, cycle detection, topological sorting and strongly connected components, Dijkstra, Bellman-Ford and DAG shortest paths, minimum spanning trees with union-find, greedy algorithms with exchange arguments and Huffman coding, and a capstone on amortized analysis and algorithm design for a real problem.
Part of the Science stream, typically taken in year 2.