Everything on the site.

Big-O notationAlgorithms · Count the steps in real loops, then compare n, n log n, n² and 2ⁿ on a live chart.RecursionAlgorithms · Watch frames push and pop on the call stack for factorial and Fibonacci.BFS vs DFSAlgorithms · A queue against a stack: draw a graph and see which order each search visits it in.Sorting algorithmsAlgorithms · Seven sorts on the same input, with comparison, swap and write counts side by side.Binary searchAlgorithms · Halve the range, probe the middle, repeat: with lo, mid and hi drawn on the array.Sets, relations and functionsDiscrete maths · Shade any set expression on a Venn diagram and test a relation for its properties.Proof by inductionDiscrete maths · Four worked proofs revealed one step at a time, and a broken one to diagnose.CombinatoricsDiscrete maths · An exact nPr and nCr calculator, and a Pascal’s triangle that shows its own addition rule.Boolean algebraDiscrete maths · The laws, De Morgan, and normal forms, with a truth-table generator built in.Finite-state machinesTheory · Build a DFA in a table, see it drawn, and run strings through it one symbol at a time.Domain theoryTheory · Why recursion needs least fixed points, and how CPOs, Scott continuity and powerdomains supply them.Truth table generatorTools · Expression in, truth table out: with DNF, CNF, a minimal form and LaTeX.Graph traversal visualiserTools · Draw a graph, then animate BFS, DFS and Dijkstra with the frontier shown.Recursion tree visualiserTools · Paste a recursive function or a recurrence and see its call tree and call count.Gradient descentML maths · Drag the starting point, set the learning rate, and watch it converge or blow up.Vectors and embeddingsML maths · Bend the plane with a 2×2 matrix and measure how close toy word vectors are.Softmax and cross-entropyML maths · Edit the logits and watch the probabilities, the loss and the gradient update live.AttentionML maths · Q, K and V for three tokens, a live score heatmap, and the weighted sum of values.Formatting a CS paper in LaTeXLaTeX · Page limits, \documentclass, front matter, theorem environments and the bibliography.Camera-ready checklistLaTeX · Fonts embedded, PDF/A, copyright form, source bundle, and why final versions get rejected.LaTeX templatesLaTeX · Where the official classes live, plus a minimal article template you can copy.AlgorithmsSection · Step-through visualisations of sorting, searching, recursion, graph traversal and Big-O growth, each with pseudocode that highlights the line being run.Discrete mathsSection · Sets, relations and functions, proof by induction, counting, and Boolean algebra, explained with worked examples and small interactive checkers.TheorySection · Finite-state machines, automata and the mathematical semantics of programming languages, explained from first principles.ML mathsSection · Gradient descent, vectors and embeddings, softmax and cross-entropy, and attention, each with a formula, a worked numeric example and a live version.ToolsSection · A truth-table generator with CNF, DNF and LaTeX output, a graph-traversal visualiser for BFS, DFS and Dijkstra, and a recursion-tree visualiser.LaTeXSection · How to format a CS conference or workshop paper in LaTeX, a camera-ready checklist, and a minimal template you can adapt.
Free tool

Recursion tree visualiser

Paste a small recursive JavaScript function and see every call it makes as a tree, with exact call counts and the arguments that repeat. Or enter a divide-and-conquer recurrence and get its recursion tree, the work per level and the master-theorem bound.

Interactive: Call-tree drawer for JavaScript functions and recurrencesUpdated

Recursion tree from a functionWrite one named recursive function. It runs in a sandboxed worker in your browser, stopped after 2 seconds or 5,000 calls.

  • Running
  • Waiting on a call
  • Returned
  • Cache hit

Totals

0Calls
0Max depth
0Distinct

Result: —

Call stack (top is running)

Most repeated calls

Tracing a function

Write one named function with the function keyword, then say what to call it with. The examples cover the common shapes: linear recursion (factorial, gcd), branching recursion (Fibonacci, binomial coefficients, Towers of Hanoi) and divide and conquer (fast power, merge-sort splitting). The tool opens on the finished tree; use the controls to rewind and replay the calls in order.

  • Calls is the total number of times the function was entered, the size of the tree.
  • Max depth is the deepest the call stack went, the height of the tree. It tells you how much stack memory the recursion needs.
  • Distinct is the number of different argument lists. When it is much smaller than the call count, the function repeats work, and memoisation will help.

Tick Memoise to cache each result by its arguments. Repeated calls then return immediately and show up as dashed purple leaves. For fib(5) the call count drops from 15 to 9; for fib(25) it drops from 242,785 to 49, and the naive tree is too large to draw.

Safety and limits Your code runs in a separate Web Worker in this browser tab. It is stopped after 2 seconds or 5,000 calls, so an infinite loop or a missing base case cannot freeze the page. Trees with more than 400 calls are counted but not drawn. Nothing is sent to a server.

Solving a recurrence

The second tab handles recurrences of the form

T(n)=a T(n/b)+f(n),T(1)=1,T(n) = a\,T(n/b) + f(n), \qquad T(1) = 1,

which describe algorithms that split a problem of size nn into aa subproblems of size n/bn/b and spend f(n)f(n) splitting and combining. Level ii of the recursion tree has aia^i nodes of size n/bin/b^i, and the tree has about log⁡bn\log_b n levels, ending in alog⁡bn=nlog⁡baa^{\log_b n} = n^{\log_b a} leaves.

The master theorem

Compare f(n)f(n) with nlog⁡ban^{\log_b a}, the number of leaves.

  1. If f(n)f(n) grows polynomially slower, the leaves dominate: T(n)=Θ(nlog⁡ba)T(n) = \Theta(n^{\log_b a}).
  2. If they grow at the same rate, every level does about the same work: T(n)=Θ(nlog⁡balog⁡n)T(n) = \Theta(n^{\log_b a} \log n). More generally, if f(n)=Θ(nlog⁡balog⁡kn)f(n) = \Theta(n^{\log_b a}\log^k n) then T(n)=Θ(nlog⁡balog⁡k+1n)T(n) = \Theta(n^{\log_b a}\log^{k+1} n).
  3. If f(n)f(n) grows polynomially faster (and satisfies a mild regularity condition, which polynomials do), the root dominates: T(n)=Θ(f(n))T(n) = \Theta(f(n)).

Worked examples

  • Merge sort, T(n)=2T(n/2)+nT(n) = 2T(n/2) + n. Here nlog⁡22=nn^{\log_2 2} = n, the same as f(n)f(n): case 2, Θ(nlog⁡n)\Theta(n \log n).
  • Binary search, T(n)=T(n/2)+1T(n) = T(n/2) + 1. nlog⁡21=n0=1n^{\log_2 1} = n^0 = 1, the same as f(n)f(n): case 2, Θ(log⁡n)\Theta(\log n).
  • Karatsuba multiplication, T(n)=3T(n/2)+nT(n) = 3T(n/2) + n. nlog⁡23≈n1.585n^{\log_2 3} \approx n^{1.585} beats nn: case 1, Θ(n1.585)\Theta(n^{1.585}), better than the schoolbook Θ(n2)\Theta(n^2).
  • Strassen’s matrix multiplication, T(n)=7T(n/2)+n2T(n) = 7T(n/2) + n^2. nlog⁡27≈n2.807n^{\log_2 7} \approx n^{2.807} beats n2n^2: case 1. With 8 subproblems instead of 7 it would be Θ(n3)\Theta(n^3).
  • T(n)=2T(n/2)+n2T(n) = 2T(n/2) + n^2. n2n^2 beats nlog⁡22=nn^{\log_2 2} = n: case 3, Θ(n2)\Theta(n^2). The top level already does half of all the work.

The table of exact values computes T(n)T(n) directly from the recurrence for n=b,b2,…,b10n = b, b^2, \dots, b^{10} and divides by the bound. If the bound is right, the ratio settles towards a constant, which is a good way to convince yourself of the answer without trusting the theorem.

Recurrences of other shapes, such as T(n)=T(n−1)+nT(n) = T(n-1) + n (selection sort, Θ(n2)\Theta(n^2)) or T(n)=T(n−1)+T(n−2)+1T(n) = T(n-1) + T(n-2) + 1 (naive Fibonacci, exponential), are outside the master theorem. Write them as a function in the first tab to see their trees.

Learn the background

The recursion explainer walks through the call stack for factorial and Fibonacci line by line, and Big-O notation explains the growth rates the master theorem produces.

References

  1. J. L. Bentley, D. Haken and J. B. Saxe, “A general method for solving divide-and-conquer recurrences”, ACM SIGACT News 12(3), 1980. doi:10.1145/1008861.1008865
  2. T. H. Cormen, C. E. Leiserson, R. L. Rivest and C. Stein, Introduction to Algorithms, 4th ed., MIT Press, 2022. Chapter 4.