Sorting Algorithms in a few Words

This note contains the basic ideas of different sorting algorithms in brief and plain words. It is for my own revision purpose and does not guarantee to be fully accurate.

Selection Sort

  • Start from A[0] (subject), find the smallest number among all elements

Bubble Sort

  • Start from A[0], compare A[0] with A[1]. Swap them if A[0] is larger

Insertion Sort

  • Start from A[1], compare A[1] with A[0]. Swap them if A[1] is smaller

Quick Sort

  • Select a pivot value

Merge Sort

  • Keep splitting the array into half until all sub-arrays contain only 1 element

Counting Sort

  • Make an array with size equal to the largest value among the numbers to be sorted. The index of the array represent the values

Binary Sort

  • Put all elements into a binary search tree

Heap Sort

  • Put all the elements into a heap

Originally published at on February 27, 2021.

正在德國深造的90後香港電腦工程師。偶爾寫寫電腦技術、時政、分享攝影作品等。| 本站: | fb: | ig: terrytsang.indigo

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store