Welcome to Compigorithm! This tool is designed to help teach Big-O complexity analysis. We offer two types of exercises:


Level 1: Analyze. Given an algorithm, analyze the complexity of each line of code, and ultimately the overall complexity of each function.
Level 2: Implement & Optimize. Given a description of an algorithm, begin by implementing it. Once correctness is achieved, guess its complexity, and then (if applicable) optimize it to improve its complexity.


For level 1, we offer a variety of curated exercises designed to reinforce specific concepts:

  • bubble_sort and selection_sort: Polynomial time sorting algorithms.
  • build_hist: Dictionary operations.
  • list_shifts and list_slices: Differentiating between O(1) and O(n) list operations. The former teaches more generalizable reasoning about array-backed lists; the latter is more Python-specific.
  • mystery: A collection of four mystery functions that cover a variety of different scenarios.
  • nested_loops_1 and nested_loops_2: Nested loops -- basic and more advanced, respectively.
  • ranges_1 and ranges_2: Iteration over ranges -- basic and more advanced, respectively.
  • subset_sums: Exponential complexity.

We also offer an interactive playground that allows users to input programs of their choosing for analysis. Note that the playground only supports a limited subset of the Python language.


For level 2, we currently offer four exercises:

  • find_exactly_twice: Find all terms that appear exactly twice in a list.<>
  • find_greater_terms: Find all terms that are greater than the sum of the preceding terms.
  • moving_avg: Compute the moving average of a list.
  • product_except_self: For each index in a list of integers, compute the product of all terms except the term at that index.

Compigorithm makes use of several open source projects, including Monaco, Bulma, SymPy, and Mypy. The license information for the frontend dependencies can be found here. It also uses icons by Font Awesome, licensed under CC-BY-4.0.