Algorithms and Data Structures [30 Days] Training Camp - Principles and Code Explanation of Merge Sort and Radix Sort (25)

merge sort


Merge sort is based on the idea of ​​divide and conquer. The divide and conquer mode has three steps on each level of recursion:

  • Divide: Divide n elements into subsequences of n/2 elements
  • Solution (Conquer): Use merge sort to recursively sort two subsequences
  • Merge: Merge two sorted subsequences to get the sorted result

insert image description here

Note that two pairs are merged; two pairs are combined; two pairs are sorted

Guaranteed internal block ordering

insert image description here

Guess you like

Origin blog.csdn.net/weixin_47723732/article/details/127477489