程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python sorting algorithm

編輯:Python

21. Sorting Algorithm

Article table of contents

    • 21. Sorting Algorithms
      • 21.1 Algorithm Stability
      • 21.2 Classification
        • 21.2.1 Stable Sorting Algorithm
        • 21.2.2 Unstable sorting algorithm
      • 21.3 Bubble Sort
        • 21.3.1 Code Implementation
        • 21.3.2 Time Complexity
      • 21.4 Selection Sort
        • 21.4.1 Code Implementation
        • 21.4.2 Time Complexity
      • 21.5 Insertion Sort
        • 21.5.1 Code Implementation
        • 21.5.2 Time Complexity
      • 21.6 Quick Sort
        • 21.6.1 Code Implementation
        • 21.6.2 Time Complexity

21.1 Algorithm Stability

Assuming that there are multiple records with the same keyword in the sequence of records to be sorted, if the relative order of these records remains unchanged after sorting, the sorting algorithm is said to be stable; otherwise, it is said to be unstable.stable

21.2 Classification

21.2.1 Stable Sorting Algorithm

  • Bubble Sort
  • Insertion Sort
  • Merge Sort
  • Radix sort

21.2.2 Unstable sorting algorithm

  • Selection Sort
  • Quick Sort
  • Hill Sort
  • Heapsort

21.3 Bubble Sort

21.3.1 Code Implementation

21.3.2 Time Complexity

  • Worst

    • O(n2)
  • Optimal

    • O(n)

21.4 Selection Sort

21.4.1 Code Implementation

21.4.2 Time Complexity

  • Optimal

    • O(n2)
  • Worst

    • O(n2)

21.5 Insertion Sort

21.5.1 Code Implementation

21.5.2 Time Complexity

  • Optimal

    • O(n)
  • Worst

    • O(n2)

21.6 Quick Sort

21.6.1 Code Implementation

21.6.2 Time Complexity

  • Optimal

    • O(nlogn)
  • Worst

    • O(n2)

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved