Comparison Lab

Two algorithms, one input. Each comparison runs both sides on exactly the same values with the same seed, plays them step by step in one 3D scene, and counts the work each side does with a definition that is the same for both.

  • Bubble sort vs insertion sort

    On the same array, how many element comparisons and array writes does each sort make, and how does that change between sorted, shuffled and reversed input?

    Element writes, “Worst case: reversed”: Bubble sort 240 · Insertion sort 135

  • Linear search vs binary search

    Searching the same sorted array for the same target, how many elements does each search have to look at?

    Elements examined, “Target at the end”: Linear search 32 · Binary search 6

  • Dynamic array vs linked list

    For the same sequence of push_back, push_front and pop_front, what does each structure have to do: move elements, allocate memory, or rewire pointers?

    Allocations, “push_front × 12”: Dynamic array 5 · Linked list 12

How the numbers are made

  • Same input, same seed. One input editor feeds every side. If an input is valid for one algorithm but not another (an unsorted array for binary search, say), it is rejected with a message rather than silently changed.
  • Defined metrics. Each metric says exactly what one unit is, for example “one evaluation of an order test between two array elements”. The numbers are summed from the events each algorithm's trace records. Where a metric has no meaning for one side, the table says so instead of showing a zero.
  • No wall-clock benchmarks. Nothing here is timed. Run time depends on the language, compiler, hardware, caches and input sizes far beyond what a visualization shows; operation counts do not, so they are what is compared.
  • Synchronized or independent. Synchronized playback advances every side by one trace step; a side that finishes first holds its final state. Independent mode gives each side its own controls.