algorithm-notes
  • Preface
  • Outline
    • Asymptotic-Analysis
    • Divide-and-Conquer (DnC)
      • Overview
      • Multiplication
      • DnC Strategy
      • Master Method
    • Randomization
      • Overview
      • Discrete Probability
      • Randomized Algorithms
      • Reservoir Sampling
    • Sorting
      • Overview
      • Selection Sort
      • Bubble Sort
      • Insertion Sort
      • Shell Sort
      • Merge Sort
      • Heap Sort
      • Quick Sort
      • Non-Comparison Sort
    • Graph Algorithms
      • Overview
      • Minimum Spanning Tree
      • Shortest Path
      • Topological Sort
    • Tree
      • Overview
      • Balanced Search Tree
        • AVL Tree
        • Red-Black Tree
        • B Tree
      • Heap
      • Disjoint Set
      • Threaded Binary Tree
      • Segment Tree
    • Searching
      • Overview
      • Binary Search
      • Graph Search
      • Hash Table
      • String Search
    • Dynamic Programming
      • Overview
      • Fibonacci Numbers
      • LCS problem
    • Greedy Algorithms
      • Overview
Powered by GitBook
On this page
  • Terminologies
  • Total Order
  • Adaptive Sort
  • Comparison-based Sort
  • In-place Sort
  • Stable Sort
  • Table of Contents
  • References

Was this helpful?

  1. Outline

Sorting

PreviousReservoir SamplingNextOverview

Last updated 6 years ago

Was this helpful?

Many of programs we see today have something to do with sorting, that given an unsorted, randomly distributed array or list, research the best approach to sort in accordance to a specified alphabetical or numerical order.

Terminologies

Key concepts are introduced in this chapter such as .

Total Order

is a binary relation on a set of elements that satisfies:

  • Antisymmetry: if a ⩾ b and b ⩾ a, then a = b

  • Transitivity: if a ⩽ b and b ⩽ c, then a ⩽ c

  • Totality: either a ⩽ b or b ⩽ a or both

Adaptive Sort

A sorting algorithm is an adaptive sort scheme if it takes advantage of existing order of an original inputs. The presortedness of the input sequence benefits the sorting algorithm to achieve better running time.

Comparison-based Sort

Sorting algorithms that sort a list of elements base only on the comparisons of pairs without knowing other aspects of elements is comparison-based sort.

Note: assumes no preliminary knowledge about input arrays and thus the "general-purpose sorting method"; if not, some could be highly useful.

Sorting Lower Bound

Proof: given a randomly distributed array of length n, assume the maximal compares required to sort the entire array is k and there is at least n! permutations to sort (each permutation is possible to yield the correct outcome); In each comparison, we obtain either a True or False that the element is displaced in the right location, then:

In-place Sort

Sorting scheme that only a constant number of elements or memory spaces are required to store outside the original array is In-place Sort.

In-place Sort only requires Ο(1) extra space to sort the array. It usually sorts on the original array thus an useful approach to minimize the memory usage while sorting.

Stable Sort

Table of Contents

References

Formal Def: every has the running time of Ω(n ⋅ log n).

2k ⩾ n!, by , 2k ⩾ (n/2)n/2, k ⩾ (n/2) ⋅ log (n/2)

According to , noting that k ⩾ cn ⋅ log (cn), Τ(n) = Ω(n ⋅ log n)

Stable sorting algorithm maintains the relative order of elements with same value. Mathematically, given two records ℛ and 𝒬 with same value, ℛ precedes 𝒬 in the original array, then a will produce a sorted array with ℛ comes before 𝒬.

- a naive swapping-based sorting algorithm.

- an improved swapping-based sorting technique.

- mostly used approach in common sorting tasks.

- a compensating algorithm for .

- a type of sorting technique based on or data structures.

- a typical DnC strategy in sorting tasks.

- a performant algorithm combined with both DnC and Randomization

- intro to several non-comparison based sorting algorithms

- Lecture Notes in Jan 16, 1996

- Lecture Notes, 2017

- Lecture notes, 2006

pigeonhole principle
asymptotic analysis
Selection Sort
Bubble Sort
Insertion Sort
Shell Sort
worst-case
insertion sort
Heap Sort
min-heap
max-heap
Merge Sort
Quick Sort
Non-Comparison Sort
ICS-161 Design and Analysis of Algorithms, UCI
CSE-373 Data Structure & Algorithms, UW
CSC-263 Lecture 13, U of Toronto
Total Order
non-comparison based sort
Stable Sort
Comparison-based Sort
worst-case
comparison-based sorting
Stable Sort