Bölüm 2 · Simülatör

Sorting Race

← Bölüm 2

Sorting Race

Run multiple sorting algorithms on the same array and compare progress, comparisons, and swaps/moves.

How to use

  • Choose an array size (8–40) and press New Array to draw random values between 10 and 99.
  • Press Start Race. Every lane performs one elementary step per tick, so the finishing order reflects the number of steps each algorithm needs on this input.
  • Speed changes the tick length; pressing Start Race again restarts the race on the same array.

Algorithms

AlgorithmBestAverageWorstNotes
Bubble SortO(n²)*O(n²)O(n²)Adjacent swaps; stable
Insertion SortO(n)O(n²)O(n²)Shifts elements; stable, fast on nearly sorted data
Selection SortO(n²)O(n²)O(n²)At most n − 1 swaps; not stable
Quick SortO(n log n)O(n log n)O(n²)Lomuto partition, last element as pivot

* This bubble sort has no early-exit flag, so it always performs n(n − 1)/2 comparisons.

For insertion sort, “moves” counts element shifts; for the other algorithms it counts swaps.