Bölüm 2 · SimülatörSorting Properties Lab? ← Bölüm 2 Algorithm Insertion SortSelection Sort Run Sort Reset key 1key 2key 3Before · records (key, tag)After KapatSorting Properties LabUse records with duplicate keys to see whether a sorting algorithm preserves the original relative order of equal keys.How to useChoose an algorithm and press Run Sort. The records are sorted by their key only; the tag (A–F) just identifies each record.The top row is the order before the run, the bottom row the order after it. A line connects each record's old and new position; lines are coloured by key.If two records with the same key swap their relative order, the lines of that key are drawn thick and dashed and the run is reported as not stable.Reset restores the original order (3,A) (1,B) (3,C) (2,D) (1,E) (3,F). Running again on an already sorted row shows how the algorithm behaves on sorted input.StabilityA sorting algorithm is stable if records with equal keys appear in the output in the same relative order as in the input. Stability matters when sorting by several keys one after another, for example first by name and then by grade.Insertion sort is stable in its standard form (it shifts only while the left key is strictly greater) and is in-place.Selection sort is typically in-place but not stable in its standard swap-based form: a long-distance swap can jump a record over another record with the same key.A single input can only show instability; showing "stable on this input" does not prove that the algorithm is stable in general.CountersComparisons count key comparisons. For insertion sort the second counter is the number of shifts, for selection sort the number of swaps.