Technology Sharing

Department of Mathematics C A Brief Introduction to Sorting Algorithms (VIII)

2024-07-08

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

Table of contents

Sorting

Selection sort O(n2)

Unstable: 48429

Merge sort O(n log n) stable

Insertion sort O(n2)

Heap Sort O(n log n)

Shell sort O(n log2 n)

Library sort O(n log n)

Bubble sort O(n2)

optimization:

Radix sort O(n · k)

Quick sort O(n log n) [divide and conquer] Unstable

Bucket sort O(nk)

Counting sort O(nk)

Pigeonhole sort O(n D)


Sorting

What is a stable sorting algorithm: the order of data remains unchanged

Selection sort O(n2) Merge sort O(n log n) Insertion sort O(n2) Heap sort O(n log n) Shell sort O(n log2 n) Library sort O(n log n) Bubble sort O(n2) Radix sort O(n · k) Quick sort O(n log n) Bucket sort O(nk) Counting sort O(nk) Pigeonhole sort O(n D):

Selection sort O(n2)

► First find the minimum value and swap it with the element in the first position

► Repeat the above process for the remaining data until the sorting is completed.

Unstable: 48429

Merge sort O(n log n) stable

Merge: If there are two separately ordered arrays, you can use double pointers to merge them into a completely ordered array

You can recursively write

You can also start from 0

Merge 1-1