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.Attention mechanismML 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.Boolean algebra calculatorTools · A Boolean expression simplifier that names the law used at every step.K-map solverTools · Fill in a Karnaugh map and see the groups, the minimal SOP and POS, and the essential terms.Logic gate simulatorTools · Wire up gates, flip the switches, and get the truth table and expression of your circuit.Regex to NFA converterTools · Type a regular expression and watch Thompson’s construction build its NFA, fragment by fragment.NFA to DFA converterTools · Enter an NFA or a regex and step through the subset construction, then minimise the DFA.DFA simulatorTools · Edit a DFA, run strings through it step by step, batch-test them and share the machine as a link.Regular expressions to automataTheory · Regex to NFA to DFA to minimal DFA, worked through on one example with every set shown.The halting problemTheory · Why no program can tell whether every program halts, with the paradox program played out.Pigeonhole principleDiscrete maths · n pigeons, k holes: why some hole gets ⌈n/k⌉, and the surprising things that follows from it.Dijkstra’s algorithmAlgorithms · Shortest paths with a priority queue: a worked table, a proof, and a graph you can redraw.Hash functionsAlgorithms · Keys in, buckets out: hash a word four ways, then watch chaining and probing handle collisions.Sorting algorithm visualizerTools · Up to seven sorts race on the same data, then step through any one of them line by line.LaTeX table generatorTools · Type or paste a table, merge cells, pick booktabs, and copy clean tabular code.Combination calculatorTools · Exact nCr with the cancelling shown, combinations with repetition, and a full list for small n.Permutation calculatorTools · nPr, nʳ, anagrams like MISSISSIPPI and round-table seatings, with exact working.AlgorithmsSection · Step-through visualisations of sorting, searching, recursion, graph traversal, Dijkstra’s algorithm, hash functions and Big-O growth, with pseudocode that follows along.Discrete mathsSection · Sets, relations and functions, proof by induction, counting, the pigeonhole principle and Boolean algebra, explained with worked examples and interactive checkers.TheorySection · Finite-state machines, regular expressions and automata, the halting problem, 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 · Free browser tools: truth tables, Boolean simplification, K-maps, logic gates, nCr and nPr, regex to NFA to DFA, sorting and graph visualisers, and LaTeX tables.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

Sorting algorithm visualizer: race seven sorts side by side

Race up to seven sorting algorithms against each other on the same input, from 8 to 100 values, then slow any one of them down and step through it line by line. Bubble, insertion, selection, merge, quick, heap and counting sort, all running in your browser.

Interactive: Sorting race (8–100 values) and a step-through visualiserUpdated

Sorting raceEvery algorithm sorts the same input, one step (a comparison, swap or write) per tick.

Algorithms in the race
Step 0

Press play to start the race.

How to use the race

  • Choose the input. Random data is the usual benchmark, but the interesting results come from the others: nearly sorted data (a few neighbours swapped), reversed data, data that is already sorted, and data with only four distinct values. Drag the size slider to set how many values there are; each change deals a new input.
  • Pick the runners with the checkboxes. Four are selected to start with; tick all seven for the full field.
  • Press play. On every tick, each algorithm performs the same number of basic steps: one comparison, one swap or one write each. The lane that finishes first did the least work on this input, not merely the work fastest. Use “Steps per tick” to speed up large inputs, and the step button to advance a single step.

Bars turn green once a value is in its final position. Colours mean the same as in the step-through visualiser below: amber for a comparison, red for a swap, purple for a write into the array.

Step through one algorithm

The race shows how much work each algorithm does. To see why, run one algorithm on its own. This visualiser narrates every step, highlights the line of pseudocode being executed, and shows the auxiliary array for merge and counting sort. You can type your own values (up to 40) and scrub backwards and forwards.

Sorting visualiserPick an algorithm, edit the values, then press play or step through.

  • Comparing
  • Swapping
  • Writing
  • Pivot / heap root
  • Key / current minimum
  • In final place

Pseudocode

    Counters

    0Comparisons
    0Swaps
    0Writes

    This algorithm

    Compare all seven algorithms on this input
    AlgorithmComparisonsSwapsWritesWorst caseStable?

    A swap exchanges two entries; a write stores one value (merge, insertion and counting sort move values by writes). Counting sort never compares two elements, which is how it beats the n log n lower bound for comparison sorts.

    Benchmark: steps on 50 values

    This is what the race reports for one fixed set of 50 values in each arrangement: comparisons first, then moves (swaps plus writes). The lowest total in each column is in bold. Your runs will differ in detail because the slider deals new random values, but the pattern is stable.

    AlgorithmRandomNearly sortedReversedFew unique
    Bubble sort1215 + 467144 + 31225 + 12111197 + 458
    Insertion sort515 + 51652 + 521224 + 1260506 + 507
    Selection sort1225 + 481225 + 31225 + 261225 + 36
    Merge sort223 + 286154 + 286145 + 286216 + 286
    Quicksort269 + 121879 + 161034 + 194437 + 78
    Heapsort409 + 243436 + 264377 + 204389 + 204
    Counting sort0 + 500 + 500 + 500 + 50

    Things worth noticing:

    • Insertion sort wins on nearly sorted data, despite its Θ(n2)\Theta(n^2) worst case. Each value only slides a short distance, so the work is close to linear. This is why library sorts such as Timsort switch to insertion sort for short runs.
    • Reversed input is the worst case for bubble and insertion sort: every pair is out of order, so they make about n2/2n^2/2 comparisons and as many moves.
    • Selection sort does not care about the arrangement. It always makes exactly n(n−1)/2n(n-1)/2 = 1225 comparisons, but never more than n−1n - 1 swaps, which matters when writing is expensive.
    • Merge and heap sort are steady: their counts barely move between arrangements, as their Θ(nlog⁡n)\Theta(n \log n) bound in every case predicts.
    • Counting sort makes no comparisons at all. It counts how often each value occurs and writes them back in order, so it does about n+kn + k steps for values below kk. It only works for small integer keys.

    Complexity at a glance

    AlgorithmBestAverageWorstExtra spaceStable
    Bubble sortΘ(n)Θ(n²)Θ(n²)Θ(1)Yes
    Insertion sortΘ(n)Θ(n²)Θ(n²)Θ(1)Yes
    Selection sortΘ(n²)Θ(n²)Θ(n²)Θ(1)No
    Merge sortΘ(n log n)Θ(n log n)Θ(n log n)Θ(n)Yes
    QuicksortΘ(n log n)Θ(n log n)Θ(n²)Θ(log n) stack on averageNo
    HeapsortΘ(n log n)Θ(n log n)Θ(n log n)Θ(1)No
    Counting sortΘ(n + m)Θ(n + m)Θ(n + m)Θ(m) for the countsYes

    A sort is stable if equal values keep their original order. That matters when you sort records by one field after another: sort by first name, then stably by surname, and people with the same surname stay in first-name order. Use the “Few unique values” input in the step-through visualiser to watch an unstable sort such as selection sort reorder equal values.

    Steps are not seconds The race counts operations, not time on a real computer. Real running time also depends on memory access patterns, branch prediction and the constant work around each step. Quicksort, for example, often beats merge sort in practice because it works in place and walks through memory in order, even when it makes a few more comparisons.

    Where to go next

    The sorting algorithms explainer covers how each algorithm works, why no comparison sort can beat nlog⁡nn \log n, and what real libraries use. Big-O notation explains what the complexity classes in the table mean, and the recursion tree visualiser draws the call tree of merge sort’s recurrence.