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

Sorting Algorithms

← Bölüm 2

Ready.

Steps: 0valuecompared / movedsorted

    Sorting Algorithms

    Pick an algorithm, press Sort and watch 16 random values (10–99) being sorted. Highlighted bars are the elements currently compared or moved; when the run finishes all bars turn green. New Array draws new values, Cancel stops a running sort, and the speed menu sets the delay between steps.

    Bubble Sort

    Compare adjacent elements and swap them when they are out of order. After each pass, the largest remaining value moves to the end.

    Insertion Sort

    Take the next element and move it left until it reaches its correct position in the sorted prefix. Efficient for small or nearly sorted inputs.

    Selection Sort

    Find the smallest remaining element and swap it into the next position of the sorted prefix.

    Merge Sort

    Split the list recursively into halves, then merge the sorted halves back together.

    Quick Sort

    Choose a pivot and partition values around it, then recursively sort the left and right partitions.

    Counting Sort

    Count occurrences of each value, then reconstruct the sorted output from those counts.

    Radix Sort

    Process numbers digit by digit, using a stable counting step for each place value.

    Bucket Sort

    Distribute values into range-based buckets, sort each bucket and concatenate the results.

    Heap Sort

    Build a max heap, then repeatedly move the root to the end and restore the heap.

    Shell Sort

    Apply insertion-sort-like passes using decreasing gaps, finishing with a standard gap of one.

    Bubble Sort

    Komşu elemanları karşılaştırır ve yanlış sıradaysa yer değiştirir. Her geçişte en büyük kalan değer sona taşınır.

    Insertion Sort

    Sıradaki elemanı alır ve sıralı ön bölümde doğru yerine kadar sola taşır. Küçük veya neredeyse sıralı dizilerde etkilidir.

    Selection Sort

    Kalan bölümdeki en küçük elemanı bulur ve sıralı bölümün sıradaki konumuna taşır.

    Merge Sort

    Listeyi özyinelemeli olarak ikiye böler, sıralı alt listeleri tekrar birleştirir.

    Quick Sort

    Bir pivot seçer ve değerleri pivotun çevresinde böler; sol ve sağ bölümleri özyinelemeli olarak sıralar.

    Counting Sort

    Her değerin kaç kez geçtiğini sayar ve sayım sonuçlarından sıralı diziyi yeniden oluşturur.

    Radix Sort

    Sayıları basamak basamak işler; her basamak için kararlı bir sayma adımı uygular.

    Bucket Sort

    Değerleri aralıklara göre kovalara dağıtır, her kovayı sıralayıp sonuçları birleştirir.

    Heap Sort

    Bir max-heap oluşturur; kökü tekrar tekrar sona taşıyıp heap yapısını yeniden kurar.

    Shell Sort

    Azalan aralıklarla insertion sort benzeri geçişler yapar; son geçişte aralık bire düşer.

    Complexity

    AlgorithmBestAverageWorstAuxiliary Space
    BubbleO(n)O(n²)O(n²)O(1)
    InsertionO(n)O(n²)O(n²)O(1)
    SelectionO(n²)O(n²)O(n²)O(1)
    MergeO(n log n)O(n log n)O(n log n)O(n)
    QuickO(n log n)O(n log n)O(n²)O(log n) avg.
    CountingO(n+k)O(n+k)O(n+k)O(n+k)
    RadixO(d(n+k))O(d(n+k))O(d(n+k))O(n+k)
    BucketO(n+k)O(n+k)O(n²)O(n+k)
    HeapO(n log n)O(n log n)O(n log n)O(1)
    Shelldepends on gapsdepends on gapsO(n²)O(1)

    The best case O(n) of bubble sort assumes the early-exit variant that stops after a pass without swaps; the animation runs the plain version.