Skip to main content
Z

Selection Sort Visualizer — Animated, Step-by-Step

Animated selection sort with step controls, speed, custom input, live comparison/swap counters and pseudocode. Runs in your browser.

Free No signup Client-side Privacy friendly Updated
/
Comparisons: Swaps / writes: Array accesses:

Code examples

Ready-to-copy reference implementations. Free to use in your own projects and assignments.

How to use

  1. 1 Press Play to watch each pass scan for the minimum and swap it into place.
  2. 2 Use Step to advance one comparison at a time as the minimum is tracked.
  3. 3 Type your own numbers into Custom input and press Apply.
  4. 4 Follow the highlighted pseudocode and the live comparison / swap counters.

Why use this tool

  • See how each pass selects the smallest remaining value and places it at the front.
  • Notice it always does the same number of comparisons regardless of input order.
  • Metrics show why it makes at most n−1 swaps — useful when writes are expensive.
  • Runs entirely in your browser. No signup, no uploads.

Frequently asked questions

What is selection sort?

Selection sort divides the array into a sorted and an unsorted part. Each pass scans the unsorted part for the minimum and swaps it to the boundary.

What is the time complexity of selection sort?

O(n²) in all cases — best, average, and worst — because the scan for the minimum always examines every remaining element.

Is selection sort stable?

No. The long-distance swap of the minimum can move an equal element past another, changing relative order. A linked-list variant can be made stable.

When is selection sort useful?

When the number of writes must be minimized — it performs at most n−1 swaps, far fewer than bubble sort. Otherwise insertion sort is usually preferred.

What is Selection Sort Visualizer?

A Selection Sort Visualizer animates how selection sort repeatedly finds the minimum of the unsorted region and swaps it to the boundary. It shows why the algorithm always performs O(n²) comparisons but at most n−1 swaps.

Features

Step-by-step animation

Watch the minimum get found and swapped to the front each pass.

Complexity

Time: O(n²) in all cases. Space: O(1). In-place; not stable. Only O(n) swaps.

100% private

Runs entirely in your browser — nothing is uploaded.

Example

Input

[64, 25, 12, 22]

Output

select 12 → [12,25,64,22]; 22 → [12,22,64,25]; 25 → [12,22,25,64] (sorted)

Common use cases

  1. 1

    Learn selection logic

    See why the comparison count is fixed at ~n²/2 regardless of input.

  2. 2

    Minimize writes

    Understand where selection sort helps when swaps/writes are costly.

  3. 3

    Contrast with insertion sort

    Compare its fixed O(n²) against insertion sort's best-case O(n).

Summary

Zerethon's selection sort visualizer animates the algorithm in your browser, repeatedly selecting the minimum of the unsorted region and swapping it into place. Selection sort always runs in O(n²) time (best, average, and worst are identical) with O(1) extra space; it is in-place but not stable. It minimizes the number of swaps (O(n)).

Category
Algorithm
Pricing
Free
Privacy
Browser-based
Signup
Not required

References

Privacy

Your data never leaves your browser unless explicitly stated. Selection Sort Visualizer runs entirely client-side — no server upload, no logging, no tracking of your input.

New to this? Read the step-by-step explanation with Big-O analysis: Learn Sorting Algorithms →

Related tools

Build, share, and grow on Zerethon Social

Free signup. Earn points, collect achievements, and connect with creators worldwide.

Sign up free