归并排序算法
归并排序
分治
- 确定分界点,mid=(l+r)/2
- 递归排序左边和右边
- ⭐归并,合二为一
模板
1 | void merge_sort(int q[], int l, int r) |
1 |
|
例题
(合并两个有序单链表)[https://leetcode-cn.com/problems/merge-two-sorted-lists/]
分治
模板
1 | void merge_sort(int q[], int l, int r) |
1 | #include <iostream> |
例题
(合并两个有序单链表)[https://leetcode-cn.com/problems/merge-two-sorted-lists/]